Search code examples
gitgit-pullgit-stashgit-resetgit-revert

Undo a pull request and stash it


I pulled my 'preprod branch' into my 'master branch' which was 8 commits ahead of master and when I pulled it, It got commited to master but haven't pushed to master yet.

I want to revert the pull and move those changes to stash to so that I can see all those changes which was there in all 8 commits together and decide whether to push it or not.

I tried git reset --soft HEAD but It is reverting back to last one commit only but I want to undo and stash all those commits(which are 8 commits in this case) which I got from preprod while pulling it into master. I can't run the command 8 times also because it undo all the pull requests from other branch also.

I tried some other commands but nothing is full filling my requirement. I don't want to pick everything manually and add it.


Solution

  • You could reset your master to the remote master:

    $ git reset --soft origin/master
    

    And then you can stash these changes if you want:

    $ git stash save