0 votes
1 view
in Devops and Agile by (20k points)

I began making changes to my codebase, not realizing I was on an old topic branch. To transfer them, I wanted to stash them and then apply them to a new branch off of master. I used git stash pop to transfer work-in-progress changes to this new branch, forgetting that I hadn't pulled new changes into master before creating the new branch. This resulted in a bunch of merge conflicts and loss of a clean stash of my changes (since I used pop).

Once I recreate the new branch correctly, how I can I recover my stashed changes to apply them properly?

1 Answer

0 votes
by (28.4k points)

First, unstage the merge conflicts using the following command:  

$ git reset HEAD . 

Then save the conflicted merge 

$ git stash

Now return to master 

$ git checkout master

In order to pull latest changes: 

$ git fetch upstream; git merge upstream/master

In order to correct my new branch: 

$ git checkout new-branch; git rebase master

In order to apply the correct stashed changes (now 2nd on the stack): 

$ git stash apply [email protected]{1}

Related questions

0 votes
1 answer
0 votes
1 answer
+5 votes
1 answer
0 votes
1 answer
asked Aug 2, 2019 in Devops and Agile by Han Zhyang (19.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...