ステージングエリアを巻き戻し、コミットをやり直す --mixedオプション
members.txtに「four」を追記、ステージとコミットを行うtest@test-PC MINGW32 /c/www/test (master)
$ echo four >> members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git add members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git commit -m "add four"
[master 46c21b0] add four
1 file changed, 1 insertion(+)
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
nothing to commit, working tree clean
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
46c21b0 (HEAD -> master) add four
a4e8c02 add two and three
84e1082 first commit
$ echo four >> members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git add members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git commit -m "add four"
[master 46c21b0] add four
1 file changed, 1 insertion(+)
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
nothing to commit, working tree clean
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
46c21b0 (HEAD -> master) add four
a4e8c02 add two and three
84e1082 first commit
ステージングエリアを巻き戻す
--mixedは既定のオプションなので省略可
test@test-PC MINGW32 /c/www/test (master)
$ git reset HEAD~
Unstaged changes after reset:
M members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add..." to update what will be committed)
(use "git checkout --..." to discard changes in working directory)
modified: members.txt
no changes added to commit (use "git add" and/or "git commit -a")
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
a4e8c02 (HEAD -> master) add two and three
84e1082 first commit
$ git reset HEAD~
Unstaged changes after reset:
M members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add
(use "git checkout --
modified: members.txt
no changes added to commit (use "git add" and/or "git commit -a")
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
a4e8c02 (HEAD -> master) add two and three
84e1082 first commit
members.txtは変更されているがステージされていない状態
ここでmembers.txtに「five」を追記しステージとコミットを行うと、「four」と「five」の追記が1つのコミットとなる。
test@test-PC MINGW32 /c/www/test (master)
$ echo five >> members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git add members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git commit -m "add four and five"
[master 768d3fc] add four and five
1 file changed, 2 insertions(+)
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
nothing to commit, working tree clean
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
768d3fc (HEAD -> master) add four and five
a4e8c02 add two and three
84e1082 first commit
$ echo five >> members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git add members.txt
test@test-PC MINGW32 /c/www/test (master)
$ git commit -m "add four and five"
[master 768d3fc] add four and five
1 file changed, 2 insertions(+)
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
nothing to commit, working tree clean
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
768d3fc (HEAD -> master) add four and five
a4e8c02 add two and three
84e1082 first commit
0 件のコメント:
コメントを投稿