I wonder if I'm wrong, first merging the master into another branch, and then merging it with the master.
Suppose I create the following branches, each of which has a separate commit:
mkdir git_merging cd git_merging/ git init touch on_master git add . git commit -m "Initial commit on master" git checkout -bx touch on_branch_x git add . git commit -m "Initial commit on branch x" git checkout master touch on_master_again git add . git commit -m "Commit on master after branching"
Now I want to unite. I usually prefer to combine master into x first and then combine x to master:
git checkout x git merge -m "Merge master into x" master echo "test results" git checkout master git merge x
That way, I can check things out before merging back into the master, ensuring that I always have a valid master branch. As far as I can tell, there are no functional differences compared to merging x directly into master:
git merge -m "Merge x into master" x git checkout x git merge master
In practice, I often come across repositories that seem to be exclusively merged back into masters. Are there any flaws in my approach? Any reasons why I shouldn't do this?
source share