--soft : uncommit all changes and move back to stage state
Create a new file, stage it (add), commit it and do soft reset HEAD^
* master
$ git checkout -b a_branch
Switched to a new branch 'a_branch'
$ git log --graph --decorate --oneline -n3
* 3d1bb52 (HEAD, master, a_branch) Noh has build ship
* bb7ebab this is john sermon
$ cal 2013 > a_test_file.txt
$ git status
# On branch a_branch
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# a_test_file.txt
$ git add a_test_file.txt
$ git status
# On branch a_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: a_test_file.txt
#
$ git commit -m"a new change commited in a_test_file.txt"
[a_branch c1a194c] a new change commited in a_test_file.txt
1 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 a_test_file.txt
$ git log --graph --decorate --oneline -n3
* c1a194c (HEAD, a_branch) a new change commited in a_test_file.txt
* 3d1bb52 (master) Noh has build ship
* bb7ebab this is john sermon
$ git reset --soft HEAD^
$ git log --graph --decorate --oneline -n3
* 3d1bb52 (HEAD, master, a_branch) Noh has build ship
* bb7ebab this is john sermon
$ git status
# On branch a_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: a_test_file.txt
#
--hard : discard all changes permanently !
All new files will be deleted and modification to all file will disappear (you cannot recover !)
Commit newly created import file and do --hard reset to make your life hell !
[a_branch 8a59c62] a new change commited in a_test_file.txt
1 files changed, 35 insertions(+), 0 deletions(-)
create mode 100644 a_test_file.txt
$ git log --graph --decorate --oneline -n3
* 8a59c62 (HEAD, a_branch) a new change commited in a_test_file.txt
* 3d1bb52 (master) Noh has build ship
* bb7ebab this is john sermon
$ git reset --hard HEAD^
HEAD is now at 3d1bb52 Noh has build ship
$ git log --graph --decorate --oneline -n3
* 3d1bb52 (HEAD, master, a_branch) Noh has build ship
* bb7ebab this is john sermon
$ git status
# On branch a_branch
nothing to commit (working directory clean
You file has been permanently deleted by Mr --hard !
No comments:
Post a Comment