1

i'm a git newbie and i'm having difficulties with merging.

Using git-flow, we have a master and a develop branch. Each feature we develop has a proper branch ( let's call it DEV-738 ).
While i develop my feature, another developer works on another branch ( let's call it DEV-750 ) and when their feature is finished it goes into develop.
I use to merge develop into feature branch, so when my feature will be completed ( i worked on it for about 4 months ) i'm going to encounter less problems. Unfortunately, merging develop into my feature branch causes some issues. I' ve spent 4 days refactoring a function using async/await, and other improvements, and when i've merge develop into my branch my refactor vanished, restoring the old version of the function.
What can I do to prevent issues of this kind in future ?

Thanks

mike
  • 1,233
  • 1
  • 15
  • 36
Tiziano
  • 316
  • 1
  • 4
  • 17
  • 2
    I'd probably start with investigating 'git rebase' and rebasing your feature branch back off the development branch – Brian Agnew Jun 24 '20 at 09:34
  • Try having a look at rebasing or continue to use merge, but use GUI for it. https://stackoverflow.com/questions/11563319/git-rebase-basics https://stackoverflow.com/questions/16666089/whats-the-difference-between-git-merge-and-git-rebase/25267150 – Tom Jun 24 '20 at 09:35
  • 2
    Also: As long as you've commited the async/await refactoring, you can still recover it. – Tom Jun 24 '20 at 09:37
  • 1
    Did you get merge conflicts? If so, how did you resolve them? I would probably reset your branch back to before that merge, and redo the merge, assuming you haven't just continued to work after the merge. – Lasse V. Karlsen Jun 24 '20 at 09:44
  • @LasseV.Karlsen No, the strange thing is that i had no conflicts. – Tiziano Jun 24 '20 at 09:54
  • @Tom yes luckly i had committed my changes so i can recover it, but i'm finding that i had issues in a lot of files and find all the missing new part can be challenging – Tiziano Jun 24 '20 at 09:55
  • What did your merge command look like? From my experience with git, there is an explanation to the behavior you're seeing, it's just not evident from your question and comments what that explanation is yet. – Lasse V. Karlsen Jun 24 '20 at 12:11
  • @LasseV.Karlsen i've used sourcetree, i never looked at the command it gave :/ – Tiziano Jun 24 '20 at 12:12

1 Answers1

2

There’s no way to avoid all merge conflicts and issues but I will give you some advice that can help you with your workflow dealing with conflicts is as simple as possible.

  1. git pull the master branch every day.

  2. git rebase master often. When you know that other developers are working on the same code and have had changes merged, rebase. This is also an alternative to merging master onto your feature that will reduce the commit history mess.

  3. Things don’t “vanish”. Learn about git reflog here and how it can help you through mistakes.

  4. Learn about git rerere here and how it can help you avoid repeating work when you encounter merge conflicts.

yes-siz
  • 348
  • 2
  • 9