Reputation: 17541
I have a specific directory where the sources where modified in a specific commit 0x0x0x0x0
. After that commit have been many other commits all on the master.
I want to cancel that commit 0x0x0x0x0
and locally(not upstream) in this specific directory have the code prior to when this commit was made.
What git commands can I run for this?
Later edit: I want just that specific commit canceled not the subsequent changes. As code it doesn't affect me since it is an independent module. Also I will not use this local repository for committing further upstream.
Upvotes: 1
Views: 264
Reputation: 758
It's possible to return to any commit with the following command:
git reset --hard commit_identifier
Note: to obtain the commit identifier use git log
command
You can also reset the last commit with command:
git commit --amend
Take a look to the next link for more information:
http://www.kernel.org/pub/software/scm/git/docs/git-reset.html
Upvotes: 1
Reputation: 388303
If you want to go back to before the commit was introduced, so effectively removing its changes and all changes that happened afterwards (in other commits), you can do the following:
git checkout -b <newbranchname> commithash~1
git reset --hard commithash~1
But if you just want to undo said commit while keeping all the changes that were made afterwards, you can just do this:
git revert commithash
Upvotes: 5