Stash the changes made with atlassian sourcetree

 ̄綄美尐妖づ 提交于 2020-06-24 03:07:49

问题


I have a lot of files changed in my project. I want to stash 2 files but i'm a bit afraid to make a mistake since i never did this.

If i would stash now, will it only stash the 2 staged files? enter image description here

And if I don't mark the "Keep staged changes", will it then revert to how it was before? This might sound stupid, but better save then sorry.


回答1:


This applies to Git in general, not just with SourceTree. When you stash changes, the items that will be stashed are the changes to tracked files in your working copy and in the staging area. Those changes will be saved in the stash, and reverted in the working copy and index.

When you choose to keep changes in the index/staging area, those changes will still be stashed, but Git won't also revert them in the staging area. This is useful if, for example, you make several unrelated changes, and you want to run tests only some of those changes, without having the unrelated ones affect the test.

Stashing is safe. If you want to get your stashed changes back, you just pop them back out of the stash.

However, untracked files aren't normally stashed. If you want to also stash those files, you need to pass an additional option to git stash on the command line (SourceTree for Windows doesn't currently have such an option. I don't know if the same is true for the Mac version):

git stash save --include-untracked
# Or shorter
git stash save -u

See Also

  • The official Linux Kernel documentation for git stash.



回答2:


Yes, but stashing in this case would mean two scenarios -

  1. Checking the Keep staged changes: staged files would still be in your staging area, but all your modified unsaved files will be stashed.

  2. Without checking the staged changes: all your files will be stashed.



来源:https://stackoverflow.com/questions/23898093/stash-the-changes-made-with-atlassian-sourcetree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!