I did a git pull
from a shared git repository, but something went really wrong, after I tried a git revert
. Here is the situation now:
This happened for me when I was trying to stash my changes, but then my changes had conflicts with my branch's current state.
So I did git reset --mixed
and then resolved the git conflict and stashed again.
I used:
git reset --hard
I lost some changes, but this is ok.
This worked for me:
Do
$ git status
And check if you have Unmerged paths
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution)
#
# both modified: app/assets/images/logo.png
# both modified: app/models/laundry.rb
Fix them with git add
to each of them and try git stash
again.
git add app/assets/images/logo.png
Use:
git reset --mixed
instead of git reset --hard
. You will not lose any changes.
To follow up on malat's response, you can avoid losing changes by creating a patch and reapply it at a later time.
git diff --no-prefix > patch.txt
patch -p0 < patch.txt
Store your patch outside the repository folder for safety.
maybe there are some unmerged paths in your git repository that you have to resolve before stashing.