-1

In the below image, both the yellow and purple branch have shoot off and merge back into the master branch. I can't get the branches to merge back in completely.

Is it because of the pushes that I labeled in red? Maybe it is because they are behind? Taking the purple branch for example, I think what happened was the purple branch was the original master, but wasn't in my repository. I forgot to pull it down when I committed my 'Optimization' so it turned into a separate branch. Then the 'New sproc and table' was made as the master again.

How do I fix this?

enter image description here

Dung Tran
  • 357
  • 1
  • 2
  • 13

2 Answers2

1

If you're looking for your history to be linear, then you want to look into fast-forward merging. Check out this other stackoverflow thread that goes in-depth regarding fast-forwards.

If you're interested in going back and fixing the existing history, let me know and I can edit this answer with suggestions, but in my experience it's more of a headache to try modifying git history than it ends up being worth.

EDIT

Looking at it some more, I would say to avoid this in the future you should try to run git fetch and git pull before you git commit to make sure you are tracking the remote branch and have the latest. If there are merge conflicts after you pull, then it's best to try stashing your local changes, running the pull, then re-apply your changes against the latest from the remote branch.

RemedialBear
  • 644
  • 5
  • 15
1

There has no sort order for two branches. Such as the commit Optimization not means in front of commit New sproc and table because they are in two separate branches.

As the below graph, B means the commit Optimization you labeled and C to G means commits from Changes filter to exclude schemas to New sproc and table:

A---B  master
 \
  C---D---E---F---G purple

When you merge purple branch into master, changes from purple branch will apply into master branch with a new commit (as H stand for commit Merge branch 'master' of https://bitbucket):

A---B---------------H  master
 \                 /
  C---D---E---F---G purple

More details about git merge, you can refer Branching and Merging in git book.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74