Reputation: 4997
I made a mistake with my git repo and need some help resolving it, as my git foo isn't that great. I have two branches I'm working on: EBT_Branch
and Scheduling_Branch
. I had some changes on on Scheduling_Branch
that I wasn't ready to commit jus yet, so I ran git stash
and git checkout EBT_Branch
. I then made a commit and ran git checkout Scheduling_Branch
and git stash apply
, which yielded the following error that I can't figure out how to resolve:
On branch Scheduling_Branch
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: dump.rdb
no changes added to commit (use "git add" and/or "git commit -a")
Before I was getting an error telling me I couldn't merge binary files, so I tried running git rm dump.rdb
to remove it from git, and then ran git stash apply
again, which is how I wound up with the above message.
At some point I accidentally committed my Redis server's dump.rdb
file. I later added it to my .gitignore
, but now I can't seem to get rid of it. What I would like to know is how can I get rid of dump.rdb
?
Upvotes: 3
Views: 2169
Reputation: 15654
It looks like the stash you created includes stashing changes to dump.rdb
, but you're trying to apply that stash to a branch where dump.rdb
has been deleted. When Git tries to apply the stash, it wants to apply the stashed change to dump.rdb
, but can't as the file doesn't exist. That's what producing the message you're seeing.
To resolve the merge conflict, just run git rm dump.rdb
again. After you've done that, the message you're seeing should disappear from the git status
output.
Of course, any time you try to apply that stash again, you'll see the same message, because the stash still contains the changes to dump.rdb
. The quickest way to fix that is to replace the stash with one that doesn't record changes to that file. Do that by using git stash apply
to apply the stash, git stash drop
to drop the stash you just applied, git rm dump.rdb
to resolve the conflict, then git stash save
to create the new stash.
(Two brief asides for completeness: 1. You could alternatively use git stash branch
to create the new stash, which is sometimes useful when dealing with merge conflicts in applying a stash. I don't think that helps here, though, given we know how to easily resolve the merge conflict. 2. Normally it's quicker to use git stash pop
which does both apply
then drop
, but in this case pop
will refuse to drop
since there are merge conflicts, thus apply
and pop
are identical in behaviour.)
To explain the .gitignore
behaviour: once you've added a file to Git, Git ignores whether it's in .gitignore
or similar – it assumes that since you've committed it, you don't want to ignore it. To get .gitignore
to actually cause Git to ignore the file, you need to remove it from Git's view of the repository.
Upvotes: 2