To stash your working directory including untracked files (especially those that are in the .gitignore) then you probably want to use this cmd:
(要存储您的工作目录,包括未跟踪的文件(尤其是.gitignore中的文件),则可能要使用此cmd:)
git stash --include-untracked
More details: (更多细节:)
Update 17 May 2018:
(2018年5月17日更新:)
New versions of git now have git stash --all
which stashes all files, including untracked and ignored files.
(新版本的git现在具有git stash --all
stash-全部隐藏所有文件,包括未跟踪和忽略的文件。)
git stash --include-untracked
no longer touches ignored files (tested on git 2.16.2).
(git stash --include-untracked
不再接触忽略的文件(在git 2.16.2上测试)。)
Original answer below:
(原始答案如下:)
Warning, doing this will permanently delete your files if you have any directory/* entries in your gitignore file.
(警告,如果您在gitignore文件中有任何目录/ *条目,这样做将永久删除您的文件。)
As of version 1.7.7 you can use git stash --include-untracked
or git stash save -u
to stash untracked files without staging them.
(从1.7.7版本开始,您可以使用git stash --include-untracked
或git stash save -u
来存储未跟踪的文件而不进行暂存。)
Add ( git add
) the file and start tracking it.
(添加( git add
)文件并开始跟踪它。)
Then stash. (然后藏起来。)
Since the entire contents of the file are new, they will be stashed, and you can manipulate it as necessary. (由于文件的全部内容都是新内容,因此将其隐藏起来,您可以根据需要进行操作。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…