trusktr
trusktr

Reputation: 45504

Why doesn't git merge changes when two branches are different but with no new commits in either branch?

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.

Upvotes: 7

Views: 5349

Answers (2)

Hakan Deryal
Hakan Deryal

Reputation: 2903

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.

Upvotes: 2

ralphtheninja
ralphtheninja

Reputation: 133208

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.

Upvotes: 6

Related Questions