-3

I work on a robotics team that uses code from the robotics competition leaders, but with our own modification made to the code. They pushed out an update to their code, but when I work on merging it into our code, GitHub wants to remove our modifications (because they are no in the head branch). What would be the best way to prevent this from happening.

Most of the changes work ok, but some I need to keep, like in the image I have attached below.

enter image description here

Charlie Fish
  • 18,491
  • 19
  • 86
  • 179
BarrowWight
  • 181
  • 2
  • 12

1 Answers1

0

Git shouldn't "insists on removing them" but should instead report it as a conflict, which you should now resolve in the way you want. If you did some "bad things" earlier in the past, Git may be fooled by an odd history structure and may solve conflicts in a wrong way. Also, if you use rerere, then maybe it remembers some wrong merge snippets and they are now reused to skip past these conflicts. You may want to review and repair such things..

But, anyways, if git merge doesn't give you a chance to solve conflicts manually, you can always add a --no-commit --no-ff flags to git merge command, and after git merge you will be able to correct the files and commit the merge manually. After that it should be OK and future merges shouldn't have problems in this parts of this files.

..hm.. unless you are merging a separate repositories/branches which don't share any history. In your Git repo, you have your codebase based on their remote code, right? Or have you copied the code without tracking information? Or maybe you previously used squash merges to merge their changes in? Anyways, it should be reported as conflict. If it is - that's normal. Just solve the conflict.

quetzalcoatl
  • 32,194
  • 8
  • 68
  • 107
  • see also http://stackoverflow.com/questions/10116190/how-can-i-determine-why-a-git-merge-deleted-some-lines-of-code and maybe http://stackoverflow.com/questions/20286535/git-merge-deleting-code-that-should-stay as well – quetzalcoatl Oct 06 '16 at 23:19
  • Can you point me to a good resource on resolving merge conflicts? I have been having trouble finding good sources on how to do that. – BarrowWight Oct 06 '16 at 23:24
  • @user173724: There are tons of written tutorials and videos. Just google for "git resolve merge conflict" or similar. I.e. this one https://www.youtube.com/watch?v=fdK_q3Pcp9s looks fine, but I prefer KDiff3: https://www.youtube.com/watch?v=-CkqiIPAzgQ It all depends on which diff/merge tool you are using.. they are all similar, but details like menus and keyboard shortcuts differ – quetzalcoatl Oct 07 '16 at 00:10