我经常遇到这样一种情况,即我git add为提交编写了一组文件,但是必须对这些文件进行修改,以便最终对这些文件进行修改Changed but not updated.
是否有一个单行程,我只能执行git add存在于Changed but not updated和Changes to be committed列表中的文件?
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
Run Code Online (Sandbox Code Playgroud)
对于上面的例子我只是想Foo.java和Bar.java,但不会FooBar.java添加到Changes to be committed:列表中.
这是一种方法:
git add -u $(git status --porcelain | grep ^MM | cut -d ' ' -f 2)
Run Code Online (Sandbox Code Playgroud)