Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo commit operation in SmartGit/Git

Tags:

git

smartgit

Want to undo commit operation in smart git. Accidently commited wrong code and now unable to recover that code.

Thanks in advance.

like image 307
Mahesh Gulve Avatar asked Jul 05 '16 11:07

Mahesh Gulve


People also ask

Can we undo commit in git?

The easiest way to undo the last Git commit is to execute the “git reset” command with the “–soft” option that will preserve changes done to your files. You have to specify the commit to undo which is “HEAD~1” in this case. The last commit will be removed from your Git history.

How do I undo a commit to a remote?

To undo the last commit from a remote git repository, you can use the git reset command. command. This will undo the last commit locally. command to force push the local commit which was reverted to the remote git repository.


2 Answers

In SmartGit, just invoke Local|Undo Last Commit; this will put your changes back to the Index. Now you may revert them partially or all together using Local|Discard.

like image 53
mstrap Avatar answered Sep 19 '22 10:09

mstrap


The actual commit command can be undone by git reset --soft @~

like image 35
Vampire Avatar answered Sep 18 '22 10:09

Vampire