可能重复:
如何仅存储已更改的多个文件中的一个文件
如何保存特定文件,将当前已修改的其他文件保存在我要保存的存储区中?
例如,如果git status给我这个:
younker % gst
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/controllers/cart_controller.php
# modified: app/views/cart/welcome.thtml
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
我只想藏匿app/views/cart/welcome.thtml,我该怎么做?有点像(但当然这不起作用):
git stash save welcome_cart app/views/cart/welcome.thtml
Run Code Online (Sandbox Code Playgroud) 我有一个很大的git项目,我愚蠢地导入到eclipse并运行autoformat.现在,项目中的每个文件都显示为已修改.而不是提交我的格式化文件,我宁愿还原我只格式化的所有文件,而不是其他更改.例如:
$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
# modified: dir/file1.cpp
# modified: dir/file1.h
# modified: dir/file2.cpp
# modified: dir/file2.h
# modified: dir/file3.cpp
# modified: dir/file3.h
# modified: dir/file4.cpp
# modified: dir/file4.h
Run Code Online (Sandbox Code Playgroud)
我知道file2.cpp,file2.h和file3.cpp已与内容修改(即,不只是格式化).我想隐藏对这三个文件的更改,然后签出一个旧版本,以便我可以在以后重新应用这些文件的更改.我宁愿避免这样的事情:
$ …Run Code Online (Sandbox Code Playgroud)