Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

You just want to go one commit back and complete your uncomplete work. Same time you don't want to lose anything you have done in that commit. For this purpose we use git reset --soft HEAD~1 or git reset --soft paste-commit-id-here command. For more information, click git reset link.


Check current status


inanzzz@inanzzz:~/project$ git status
On branch branch-one
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: file_five.txt
modified: file_four.txt

Untracked files:
(use "git add <file>..." to include in what will be committed)

file_eight.txt

no changes added to commit (use "git add" and/or "git commit -a")

Commit


inanzzz@inanzzz:~/project$ git add --all
inanzzz@inanzzz:~/project$ git commit -m 'Second commit in branch-one branch'
[branch-one db8957f] Second commit in branch-one branch
3 files changed, 2 insertions(+)
create mode 100644 file_eight.txt

Check commit log


inanzzz@inanzzz:~/project$ git log
commit db8957fb94f9a32bca1ae57d4e6ed8340efb9c6b
Author: inanzzz
Date: Sat Mar 14 11:41:31 2015 +0000

Second commit in branch-one branch

commit 2ed26e52092851f40ea4fec60d357cd138f04209
Author: inanzzz
Date: Sat Mar 14 11:40:05 2015 +0000

First commit in branch-one branch

commit 1c5d63e1a8296bffbdda34863a91851ec3fcb665
Author: inanzzz
Date: Sat Mar 14 11:38:48 2015 +0000

Second commit in develop branch

commit f2af40db65826acd4606986acc1a9738297b1efb
Author: inanzzz
Date: Sat Mar 14 11:37:32 2015 +0000

First commit in develop branch

Revert last commit


This will remove commit "db8957fb94f9a32bca1ae57d4e6ed8340efb9c6b" from the log.


inanzzz@inanzzz:~/project$ git reset --soft HEAD~1

or


inanzzz@inanzzz:~/project$ git reset --soft 2ed26e52092851f40ea4fec60d357cd138f04209

Check commit log


inanzzz@inanzzz:~/project$ git log
commit 2ed26e52092851f40ea4fec60d357cd138f04209
Author: inanzzz
Date: Sat Mar 14 11:40:05 2015 +0000

First commit in branch-one branch

commit 1c5d63e1a8296bffbdda34863a91851ec3fcb665
Author: inanzzz
Date: Sat Mar 14 11:38:48 2015 +0000

Second commit in develop branch

commit f2af40db65826acd4606986acc1a9738297b1efb
Author: inanzzz
Date: Sat Mar 14 11:37:32 2015 +0000

First commit in develop branch

Check current status


As we can see everything is back.


inanzzz@inanzzz:~/project$ git status
On branch branch-one
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: file_eight.txt
modified: file_five.txt
modified: file_four.txt