Merge Conflicts with Update

I am trying to get started with git in a github project. (I have been using CVS, SVN and hg for many years, git is hard to get my head). I follow the instructions as accurately as I can, and simply cannot make it work.

I am cloning my forked project:

git clone git@github.com :davidgiven/linux-allwinner.git 

As recommended, I add a remote upstream channel that tracks the project from which one of them branches out:

 git remote add upstream https://github.com/amery/linux-allwinner.git 

I extract from it:

 git fetch upstream 

It all works great. But a week or so has already passed since I forked the project and changes were made upstream. Therefore, I want to make these changes. I am now in the correct branch --- allwinner-v3.0-android-v2 --- so I am merging from the branch up my branch:

 git merge upstream/allwinner-v3.0-android-v2 

... and I get merge conflicts.

 CONFLICT (add/add): Merge conflict in arch/arm/mach-sun5i/pm/standby/common.h CONFLICT (add/add): Merge conflict in arch/arm/mach-sun5i/pm/standby/Makefile CONFLICT (add/add): Merge conflict in arch/arm/mach-sun5i/pm/standby.S CONFLICT (add/add): Merge conflict in arch/arm/mach-sun5i/pm/Makefile [etc] 

Now I have not checked anything; I have not yet started work, and my project is completely untouched, since I forked it. Therefore, there should be no conflict. But there are some; what is happening and how to fix it?

Update:

git show-branch HEAD upstream/allwinner-v3.0-android-v2 shows this, that I have to say I don't understand the word:

 ! [HEAD] arm: sun3i: add getioaddr macro ! [upstream/allwinner-v3.0-android-v2] arm: sun3i: updated irq handling and machine_desc to 3.0 -- + [upstream/allwinner-v3.0-android-v2] arm: sun3i: updated irq handling and machine_desc to 3.0 + [upstream/allwinner-v3.0-android-v2^] arm: sunxi: renable early_printk in all _defconfig except crane's + [HEAD] arm: sun3i: add getioaddr macro + [HEAD^] arm: sun3i: add dummy machine type 
+7
source share
2 answers

It is possible that upstream rewrote the history (rebase, modify, ...) - they should not do this, but you will never know.

Since you say that you do not have local changes or commits, you should return your repository to a clean state by dropping the branch:

 git reset --hard upstream/allwinner-v3.0-android-v2 

( This will undo any local changes and make the commit of the current HEAD inaccessible! )


The above assumes that you (forcibly) push the new reset status of your branch to a remote repository, otherwise you will again encounter conflicts when you try to extract from origin .

 git push origin +allwinner-v3.0-android-v2 

If you already worked locally, you will have to reinstall (or cherry) your commits on top of the upper branch, and then push to the origin. So you rewrite your local history the same way you do upstream, and apply your changes from the top, i.e.:

 git rebase --onto upstream/branch \ last-original-upstream-commit-before-yours \ your-branch 
+11
source

The show-branch output means that upstream and HEAD each add two commits from their common ancestor (assuming the full output). (See also: http://www.gitguys.com/topics/git-show-branch-to-see-branches-and-their-commits/ ). If you didn’t do anything yourself, it means that a rebase has been pressed upstream (or something else that has changed history). Since you did nothing, knittl's answer is exactly what you want.

What it's worth, I also love git log --oneline --graph --decorate --remotes --branches for this. You will get an ASCII graph with all your branches and remotes so you can visualize what happened there.

+2
source

All Articles