git 命令仅在文件夹中添加/暂存修改过的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3901099/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git command to add/stage modified files in folders only
提问by lurscher
I've modified several files in a folder and subfolders. I could add the top folder recursively but then i have several subfolders that are untracked, so every time I do the recursive add to stage changes, I have to untrack the subfolders with git rm -r --cached
. Is there a better way to just stage the modifications that show up in git status, without tracking already explicitly untracked files?
我修改了文件夹和子文件夹中的几个文件。我可以递归添加顶级文件夹,但是我有几个未跟踪的子文件夹,所以每次我对阶段更改进行递归添加时,我都必须使用git rm -r --cached
. 有没有更好的方法来暂存显示在 git status 中的修改,而不跟踪已经明确未跟踪的文件?
meta-question: is it really a good idea that git add
means two (or more) things? in this context, if the command to track files (git add
) were not the same used for stage modifications (git add
) then i would not have this problem in the first place
元问题:这真的是一个好主意,git add
意味着两件事(或更多)吗?在这种情况下,如果跟踪文件的命令 ( git add
) 与用于阶段修改 ( git add
) 的命令不同,那么我首先不会遇到这个问题
回答by max
git add -u
adds only modifications. Also consider adding files which you don't want to track to .gitignore
file.
git add -u
仅添加修改。还可以考虑将您不想跟踪的.gitignore
文件添加到文件中。
回答by Nigel
I think what you're looking for is
我想你要找的是
git commit -a
This will let you commit changes only.
这将让您只提交更改。