Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "delete/modify" conflict caused by "git stash apply"

Tags:

git

I recently did a git stash, then did some work on the branch and committed it, and got these errors when trying to do a git stash apply:

CONFLICT (delete/modify): app/controllers/orders_controller.rb deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of app/controllers/orders_controller.rb left in tree.
CONFLICT (content): Merge conflict in app/models/product.rb

git status shows the following:

 $ git status
# On branch develop
# Your branch is ahead of 'origin/develop' by 16 commits.
# Unmerged paths: 
#   (use "git reset HEAD <file>..." to unstage)
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#
#   deleted by us:      app/controllers/orders_controller.rb
#   both modified:      app/models/product.rb

The file marked "delete/modify" was a new file that I added and hadn't yet committed before the stash.
I'd like to be back in the state I was in before the git stash -- having uncommitted local changes. Can you suggest how to make that happen?

Thanks.

like image 882
stupakov Avatar asked Apr 07 '12 16:04

stupakov


People also ask

How do I resolve conflicts after git stash?

Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards. If the --index option is used, then tries to reinstate not only the working tree's changes, but also the index's ones.

How do I abort a git stash conflict?

When popping out commits using the git stash pop command, you will have some merge conflicts sometimes, you can move to resolve those conflicts or abort the whole process. command. This has worked for me.

How do I recover a change in git stash?

To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.

How do you get rid of stashed changes?

Remove your stash The only way to revert it is if you didn't close the terminal after deleting the stash. If you no longer need a particular stash, you can delete it with: $ git stash drop <stash_id> . Or you can delete all of your stashes from the repo with: $ git stash clear .


1 Answers

This worked for me.

Do a-

git mergetool

Then you would be asked to pick the modified or deleted file or abort, and after this do one more time-

git mergetool

This would resolve the merge conflict and you can stash pop your changes.

like image 174
raj240 Avatar answered Oct 14 '22 00:10

raj240