abdulla syed
abdulla syed

Reputation: 161

Will merging the same branch again cause any issues in Git

Git branch screenshots !

The merge graphs shows the red and violet branches merged back into pink a couple of times. The green branch can now not be merged. Can somebody explain what should have been done after the first merge. Where did it go wrong?

Upvotes: 0

Views: 266

Answers (1)

Briana Swift
Briana Swift

Reputation: 1217

Technically, this will function. Git is always looking for lines within files, so as long as there aren't changes on the same lines of the same files, you'll be good to go. Even if the changes are on the same lines, Git will let you know there's a merge conflict.

But, is it the right way to do things? That depends on the workflow your team agrees upon.

Generally speaking, I would only change a few things:

  • Instead of merging red into purple (two feature branches), after merging red into master, I would reverse merge master into purple. This will achieve the same effect you achieved, but if there are more people working with other commits, it's a cleaner way of doing things.
  • Delete branches after you have merged them.
  • If another branch cannot be merged into master, like green, try reverse merging first and handling any merge conflicts on the feature branch before trying to merge into master.

Upvotes: 1

Related Questions