Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove last pull github

Tags:

git

github

I was working on develop branch. I committed my code and switched to another branch feature/2.10.9. I had to take the latest from feature/2.10.9,but by mistake I run the following command

git pull origin develop

instead of

git pull origin feature/2.10.9

which pulled latest code from develop branch. And git status is showing following output:

On branch feature/2.10.9
Your branch is ahead of 'origin/feature/2.10.9' by 5 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

But I don't want to push develop branch changes to that feature/2.10.9. What should I do to abort current push.

Thanks


2 Answers

You need to basically undo the merge done by running git pull origin develop instead ofgit pull origin feature/2.10.9.

First on your local, do a

git reflog to get the SHA-1 of the commit before the faulty pull (the last stable state).

To undo the merge -

git reset --hard <SHA-1 of commit obtained above>

Note that all of this should be done while you are in the feature/2.10.9 branch. After these steps you will be in the same state as you were before the incorrect merge. Now you can safely run git pull origin feature/2.10.9 that will fetch and merge the latest from the remote feature/2.10.9

like image 106
gravetii Avatar answered Mar 05 '26 22:03

gravetii


simply reset by one

git reset --hard HEAD^1
like image 36
tarikakyol Avatar answered Mar 05 '26 22:03

tarikakyol