I have cloned repository and went to branch developer
(git checkout developer
). I would like to locally revert commits (to commit with SHA: 2403d2547f9183531bbd81672d887186bba34579
) which someone made, pushed and merged to branch developer
. I don't want to change anything on repository, just locally on my machine. How can I revert this?
Just do git revert
, or whatever else you want to do, and don't push the changes.
By default, whatever you do in a git repository is done locally, and you need to use the push
command to push the changes. So just do the change, and don't do a git push
.
If you want to revert a specific commit, and preserve everything else, you can use git revert commit_sha
.
But in this case, it also looks like what you may really want is "revert" a specific commit and all the commits after it. In this case, if you don't want to push it (for example, you just want to compile the specific version of the code, or do some debugging of that specific version) you may want to use git reset --hard commit_sha^
which will "go back" to state from before the commit_sha
, or git reset --hard commit_sha
to go back to the state at the exact commit_sha
with this commit still included.