我经常遇到这样的情况:我已经使用git add
将一组文件添加到提交中,但后来又必须修改这些文件,因此在Changed but not updated
中出现了这些文件的修改。
有没有一行命令可以只将存在于Changed but not updated
和Changes to be committed
列表中的文件添加到git add
中?
markdsievers$git status
# On branch master
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: src/com/foo/Bar.java
# modified: src/com/foo/Foo.java
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: src/com/foo/Bar.java
# modified: src/com/foo/Foo.java
# modified: src/com/foobar/FooBar.java
对于上面的示例,我只想要Foo.java
和Bar.java
但不想要FooBar.java
添加到要提交的更改:
列表中。
git add -u
以外的其他方法? - Greg Hewgillgit add -u
似乎需要一个文件模式,否则它会使用.
添加Foobar.java
。是的,我可以添加一个文件模式来解决我的矫揉造作的示例,那样可以起作用,但是更改通常不会那么简单,一个单一的文件模式可能行不通。 - markdsievers