I work in a branch called master2
, the thing is that I made small changes in 1 file and when I tried to upload them, I made a mistake and git pull origin master
when push
I did, almost all the files in the repository with conflict appeared, I tried to solve them but there was no case. I need to go back to the latest stable version of the repository or if it is possible, revert the changes or delete thecommits
EDITION
There are 4 commits after the one you want to go back, can you go back 4 commits before?
You can go back to an old revision by using
checkout
and passing the commit hash. For example:Don't forget the period at the end. You can also discard changes by
reset
passing the number of commits. For example, to discard the last 3 commits:The difference between
checkout
andreset
is that in the latter revisions are discarded , while withcheckout
they are preserved.In your case you probably don't want to keep the changes so:
Or just use the commit id:
If you want to keep the changes and go back 4 commits earlier:
If you only want to move the head to 4 gears before:
You can go back to the last commit of the branch with
git reset --hard
(check that you are on the correct branch withgit status
).You can also see your previous commits with
git log
and choose one of those commits withgit checkout codigo_del_commit
.Unfortunately you will have to search for a stable version of your project using old commits, (git uses commits as save points).
If you don't save the game and you get killed, you revive at the last save point.
to return without using reset (discarding everything you've done in those commits) use
or you can use
to return 1 commit from the head you are pointing to (you can also use HEAD~2)