Undo git pull origin main? [duplicate]
is it possible to undo a git pull origin main? I did it accidentally on a branch I did not wanted to download changes, is there a command to undo it or restore this repository to what it was before doing the pull?
Here are some options:
- Ultimately you'll do a pull anyway so you could just continue work from where you are.
- Scan the history of the branch you want to rewind and find the last commit you want and rewind the branch to that spot:
- create another branch from that commit, or
git reset --hard commit_id()
if you're sure about what you're doing; this will "remove" all the commits and make the branch's tip *commit_id`
- Check
git reflog
and you should find an entry that sayspull:
and you could rewind to that.
精彩评论