无法在 git 塔中存储新的 img 文件

Cant stash new img files in git tower

我正在使用 Tower 2 来管理我的 bitbucket git 存储库。我在 repo 中添加了一些 img 文件并编辑了一些 html 和 js 文件,这些文件还没有准备好提交,所以我将它们保存为 stash。这适用于 html 和 js 文件,这些文件被编辑归档(而不是新文件),新文件所在的 img 文件,但它不允许我存储这些文件。

有没有办法存储新文件或需要先提交它们?

这不是 git-tower 的答案,因为我不使用它并且对此一无所知,而只是关于 git stash.

的一般观点

默认情况下,git stash(其默认操作是执行 git stash save)保存当前索引的内容(即,您到目前为止构建的下一个提交)和内容当前工作树,通过两次提交来实现。因为它进行提交,所以它遵守通常的提交规则:只有已经在索引中的文件才会被提交。这意味着未隐藏未跟踪和忽略的文件。

但是,git stash save 的命令行版本确实有两个标志,您可以提供这些标志来修改此行为。 -u--include-untracked 标志告诉它保存未跟踪的文件,而 -a--all 标志告诉它保存所有(未跟踪和忽略的)文件。使用这些标志时,git stash save 也简单地进行 third 提交,以保存这些文件。

git stash save 做的棘手的事情是将这两个或三个提交 放在 通常的分支系统之外,作为侧面的一种包。它还会在通过提交保存状态后清理(通过 git reset --hard 以及使用 -u-agit clean 时的工作树。

这些技巧很方便,但是can be confusing。对于 git 的新手,从普通提交开始可能更好,因为您应该拥有用于获取私有(未发布)提交并修改和组合它们的工具(例如,通过交互式 rebase 和 squash)。

TL'DR:是的。

其实有两种方式:

使用 Tower 2 存储未跟踪的文件

来自Tower 2 Manual

Saving Changes on a Stash

Since stashing is such an important feature, Tower makes using it very easy: in the toolbar, you can click [Save Stash] or press [⌘ + ⇧ + S] at any time to save your current local changes.

Providing a short but descriptive message will help you distinguish different Stashes later. As an option, Tower also offers to include untracked files when saving a Stash. (emphasized by myself)

您需要做的就是 check the little checkbox following the textfield 在 Save-Stash-Dialog 中输入隐藏消息。

软件故障

如果你这样做了,但你的藏品没有正确保存,你可能应该与 Tower Support 团队联系。为了让他们的工作更轻松,您可能需要先通过命令行测试存储。

使用命令行客户端存储未跟踪的文件

无论您使用什么软件,您始终可以通过命令行工具手动存储。

您要查找的命令是git stash save -u

了解 git-stash

answer explains what is going on with git stash under the hood, I highly suggest you read it and the linked question. In a nutshell Tower does use the command line tools internally and gives you a sophisticated GUI interface for it. As always, you can dive into details and options via the manual on git-stash.