コマンドヘルプ
git コマンド名 -hHEADが指すブランチの移動(コミットをまとめる) --softオプション
c:\www\test フォルダを作成し numbers.txtを作成、コミットを3回行う。test@test-PC MINGW32 /c/www (master)
$ mkdir test
test@test-PC MINGW32 /c/www (master)
$ cd test
test@test-PC MINGW32 /c/www/test (master)
$ git init
Initialized empty Git repository in C:/www/test/.git/
test@test-PC MINGW32 /c/www/test (master)
$ echo one > 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 "first commit"
[master (root-commit) 84e1082] first commit
1 file changed, 1 insertion(+)
create mode 100644 members.txt
test@test-PC MINGW32 /c/www/test (master)
$ echo two >> 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 "second commit"
[master b16c48a] second commit
1 file changed, 1 insertion(+)
test@test-PC MINGW32 /c/www/test (master)
$ echo three >> 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 "third commit"
[master b09f9d8] third commit
1 file changed, 1 insertion(+)
$ mkdir test
test@test-PC MINGW32 /c/www (master)
$ cd test
test@test-PC MINGW32 /c/www/test (master)
$ git init
Initialized empty Git repository in C:/www/test/.git/
test@test-PC MINGW32 /c/www/test (master)
$ echo one > 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 "first commit"
[master (root-commit) 84e1082] first commit
1 file changed, 1 insertion(+)
create mode 100644 members.txt
test@test-PC MINGW32 /c/www/test (master)
$ echo two >> 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 "second commit"
[master b16c48a] second commit
1 file changed, 1 insertion(+)
test@test-PC MINGW32 /c/www/test (master)
$ echo three >> 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 "third commit"
[master b09f9d8] third commit
1 file changed, 1 insertion(+)
ログを確認
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
b09f9d8 (HEAD -> master) third commit
b16c48a second commit
84e1082 first commit
$ git log --oneline --decorate
b09f9d8 (HEAD -> master) third commit
b16c48a second commit
84e1082 first commit
HEADを2つ前のコミット(84e1082)に戻し、b09f9d8、b16c48a のコミット履歴を削除する
test@test-PC MINGW32 /c/www/test (master)
$ git reset --soft HEAD~2
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
84e1082 (HEAD -> master) first commit
$ git reset --soft HEAD~2
test@test-PC MINGW32 /c/www/test (master)
$ git log --oneline --decorate
84e1082 (HEAD -> master) first commit
履歴は削除されたが members.txt の内容は 最新の状態のまま残っている。
$ cat members.txt
one
two
three
one
two
three
test@test-PC MINGW32 /c/www/test (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD..." to unstage)
modified: members.txt
members.txtはステージングエリアに残っている状態(modified)$ git status
On branch master
Changes to be committed:
(use "git reset HEAD
modified: members.txt
この状態でコミットすれば最新の状態でコミットされる。
test@test-PC MINGW32 /c/www/test (master)
$ git commit -m "add two and three"
[master a4e8c02] add two and three
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
a4e8c02 (HEAD -> master) add two and three
84e1082 first commit
$ git commit -m "add two and three"
[master a4e8c02] add two and three
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
a4e8c02 (HEAD -> master) add two and three
84e1082 first commit
0 件のコメント:
コメントを投稿