CrazySabbath
CrazySabbath

Reputation: 1334

Wrong merge with mergetool after rebase

I was trying to merge my local branch with my development branch (both are local, but development is up to date with remote development branch). After I did rebase, I got few conflicts, and when I solved them, I noticed that while merging one file I disregarded development branch commit for it. I checked out this file to latest commit, but now it is being shown as having changes (both Eclipse and git status show it needs to be commited).

Command sequence:

(local_dev_branch)
git pull
git checkout local_branch_from_dev
(local_branch_from_dev)
git rebase local_dev_branch
(conflicts appear)
git mergetool 
git rebase --continue
(noticed wrong file)
git checkout newest_commit_id wrong_file
git status
(and it shows that wrong_file is modified)

I am new to github, so this is still a bit confusing for me. Is it possible to somehow restore the file without having to commit it again later?

Upvotes: 2

Views: 261

Answers (1)

kowsky
kowsky

Reputation: 14449

In general, when your working directory is clean and you do a checkout of a previous version of a file, the file will of course be shown as changed. In comparison to the latest state of your repository (i.e. the HEAD commit of your branch), the file content did change.

What's wrong with committing the new version?

Alternatively, you can reset to the state before the rebase and do it again, this time taking the right version of the file from the start (assuming things went wrong during the merge while rebasing). See this answer on how to undo a rebase.

Upvotes: 1

Related Questions