How to make git commit only tracked files

时间:2015-10-30 22:32:16

标签: git svn github version-control

I've just started to use git and It's driving me nuts. If I'm understanding the way git works correctly:

  1. Even if a file is tracked you have to add it to the staging pool before committing it.
  2. Only files in the staging pool will be committed to the local repository.
  3. When a non tracked file is added to the staging pool with 'git add' it automatically becomes a tracked file.
  4. When a tracked file is deleted with 'git rm' (or 'git rm --cached' if I don't want it to be deleted from the FS) a delete 'action' is inserted into the staging pool that will be implemented in the local repository on the next 'git commit'.

However, if I have a 100 tracked files that have been modified adding them all individually in preparation for a commit is pretty tedious. When I do a svn commit from the root of my tree subversion will by default commit only tracked files that have been modified added with 'svn add' or deleted with 'svn rm'.

So the question is, is there a single git command that will do what 'svn commit' does, i.e. add and commit only all the tracked files that have been modified or deleted and not add every single solitary file in the tree to the staging pool?

1 个答案:

答案 0 :(得分:5)

git add -u should add only modified and removed files.