git-rollback-1-pull
git-how-to-undo-a-git-pull
Error:
Auto-merging push/tripshow.blade.php
CONFLICT (content): Merge conflict in push/tripshow.blade.php
Automatic merge failed; fix conflicts and then commit the result.
Solution
How to undo a git pull
Sponsor
Have you ever been working on a project, ran a git pull only to realise you’ve majorly messed up? Now all your code has been overwritten with whatever was in your remote repository - and sometimes this isn’t what you want. In times like this, it’s easy to panic, but fortunately there are a few ways to revert your code back to its old state and undo the git pull.
First things first, make a copy of your project in case you cause things to get worse. Also note that these commands will cause you to lose all uncomitted changes - so a backup can help you save that stuff before you continue. At least then, you’ll have the version you currently have. After you’ve done this backup, you’ll want to get a list of all your commit history. You can do this by running git reflog:
git reflog
How to undo a git pull
Have you ever been working on a project, ran a git pull only to realise you’ve majorly messed up? Now all your code has been overwritten with whatever was in your remote repository - and sometimes this isn’t what you want. In times like this, it’s easy to panic, but fortunately there are a few ways to revert your code back to its old state and undo the git pull.
First things first, make a copy of your project in case you cause things to get worse. Also note that these commands will cause you to lose all uncomitted changes - so a backup can help you save that stuff before you continue. At least then, you’ll have the version you currently have. After you’ve done this backup, you’ll want to get a list of all your commit history. You can do this by running git reflog:
git reflog
This will generate a list that looks like this:
648e314 (HEAD -> master, origin/master) HEAD@{0}: commit: Design refresh
b0168ee HEAD@{1}: commit: Minor CSS tweaks
514a02f HEAD@{2}: commit: Fixed extra curly brace
b432ba7 HEAD@{3}: commit: fixed border-radius
a707d13 HEAD@{4}: commit: fixed image border-radius
abf89a3 HEAD@{5}: commit: updated look and feel
Select the version you want to revert to. For example, if I wanted to revert to ‘Minor CSS tweaks’, I’d select the ID b0168ee. Next, run the following command to revert your repository to that
git reset --hard b0168ee
git reset --hard HEAD^1
Top comments (0)