问题
For example,
I my master branch has stuff in it. Another branch called other_branch
has stuff+more_stuff in it. Each branch has nothing to commit.
If I checkout master then try to merge other_branch, git says "Already up-to-date." and nothing happend. why won't more_stuff be merged into master in this case? Is that how git was designed?
NOTE: other_branch was created from an older commit of master.
回答1:
It's very simple. If git says "Already up-to-date" it means the branches have not diverged. Two branches have diverged if at least one of the branches contains a commit that the other branch doesn't have.
I'm not sure what you mean by has stuff + more_stuff in it. If you have added new files to other_branch (or changed existing files), and used "git add" and "git commit" other_branch history will have diverged from the master branch. Since git says that there are no changes to merge, the history hasn't changed on that branch, i.e. you haven't committed anything.
回答2:
It only happens when the the branch you are trying to merge is already contained in the current branch.
So, the more_stuff
you mentioned is already in the master branch.
You can use gitk
to check the visual tree of your branches.
来源:https://stackoverflow.com/questions/9763443/why-doesnt-git-merge-changes-when-two-branches-are-different-but-with-no-new-co