Reputation: 2777
Before you begin spewing git commands, I use Windows 7-64bit with TortoiseGit (currently v1.7.11.3) exclusively as I am new to Git.
My DEV branch is older than current remote master and I update DEV, and resolve conflicts.
DEV branch has pushed commits to remote DEV branch, thus rebase
is not possible - as I understand it.
Why does this behaviour happen and how can I avoid it ?
Checkout master
(switch to local master)Pull origin master
(No conflicts)Checkout DEV
(switch to dev branch)Merge master
(apply local master changes into local DEV branch)commit
modified files (both auto-merged and fixed conflict files)When I open the log
then I see "parent 1" files as in the commit window AND "parent 2" files, which werent shown. Here is the odd part, files that the (local/remote is same) master had deleted are now added and new files are deleted.
Additionally, "parent 2" files did not produce any conflicts despite some should!
The new/deleted files work the opposite of what I expected. Why is that ?
If a file is new in master and I merge into DEV branch, then I expect it to exist after the merge.
My guess is that DEV branch is considered primary, and not the branch (master) I merge into DEV.
I do not have the option to use Revert
to re-create deleted files (those that are actually new in master).
Upvotes: 1
Views: 2493
Reputation: 8200
Your merge direction is incorrect as i see it:
You should do:
git checkout master
git pull origin master
here you have two variants:
1) if you don't want to rewrite dev branch history on the remote then yo got to keep it as is but to do
git merge dev # will produce merge commit if not fast-forward
2) or if you don't care much about dev branch history
git checkout dev
git rebase master # now all commits that happened in dev will be "on top" of master, master will be behind
git checkout master
git merge dev # will result in fast-forward merge without merge commit
Now in order to go back to the state before the faulty merge you can just do (if the merge is the last thing you did in dev branch):
git checkout dev
git reset --hard HEAD~1
Now you can merge properly. In second case the push of dev branch to remote dev most times will be prohibited as non-fast-forward unless you will use -f flag. Hope that helps.
Upvotes: 2