git commit -aでコミットされるファイルを確認するにはgit status。この状態でgit commit -aすると、po/ja.poとsrc/gui/curses/gui-curses-chat.cの両方の変更に対してコミットログを書くべき。だけど、src/gui/curses/gui-curses-chat.cに対する仕事はまだ完了していないので、仕事完了したpo/ja.poの変更内容だけをコミットしたい。
$ git status # On branch master # Your branch is ahead of 'origin/master' by 4 commits. # # 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: po/ja.po # modified: src/gui/curses/gui-curses-chat.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # ************ # ************* # ************ # ********* # ************************************* # **** no changes added to commit (use "git add" and/or "git commit -a")
git addでコミットするファイルを指定。この状態でgit statusを見ると、src/gui/curses/gui-curses-chat.cはコミットから外れることがわかる。
$ git add po/ja.po $ git status # On branch master # Your branch is ahead of 'origin/master' by 4 commits. # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: po/ja.po # # 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/gui/curses/gui-curses-chat.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # ************ # ************* # ************ # ********* # ************************************* # ****
実際にコミットする。このとき、git commit -aではなく、git commitであることに注意。
$ git commit translation: update # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # On branch master # Your branch is ahead of 'origin/master' by 4 commits. # # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: po/ja.po # # 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/gui/curses/gui-curses-chat.c # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # ************ # ************* # ************ # ********* # ************************************* # ****