直前に行ったcommitを取り消したい

「git reset --soft HEAD^」で、直線のcommit(レポジトリへの登録)を取り消します。

$ git status 
# On branch master
nothing to commit, working directory clean
$ git reset --soft HEAD^
$ git status 
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   xxx
#	modified:   yyy
#	modified:   zzz
#

ここでさらに、全てのファイルをインデックスからも消したい場合は

$ git reset HEAD .

(最後のピリオドに注意)とアンステージします。

ここで、もしもファイルxxxだけcommitしたいならば、その他のファイルyyyとzzzをアンステージする必要があります。ので以下のようにします。(Gitが説明してくれていますけどね。)

$ git reset HEAD yyy zzz
Unstaged changes after reset:
M	yyy
M	zzz
$ git status 
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   xxx
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   yyy
#	modified:   zzz
#

ここでcommitすればファイルxxxだけが対象になります。

$ git commit -m 'ファイルxxxを修正'
[master 599f31f] ファイルxxxを修正
 1 file changed, 1 insertion(+)
$ git status 
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   yyy
#	modified:   zzz
#