3

I have a master branch, and another_branch with twice as many files in it.

How come when I git checkout master then git merge another_branch it says Already up-to-date. and doesn't merge the extra files into master?

(Yes, i have already done git add . while having another_branch checked out. git commit says there is nothing to commit.)

I already saw this post and this post, but so far nothing worked.

EDIT: The master branch has files, and the another_branch branch has the same files plus more. Why won't those extra files be merged?

EDIT: I solved the problem by copying the files from another-branch to an external folder, checking out master, copying the files back in from the external folder, and adding all the new files and making a new commit.

Come to think of it, I think if I made a small change in another_branch then committed, I would have been able to merge everything into master, but I didn't get to try it out.

Community
  • 1
  • 1
trusktr
  • 44,284
  • 53
  • 191
  • 263

1 Answers1

0

You must commit your files on another_branch. Simply adding them with git add . is not enough.

rtn
  • 127,556
  • 20
  • 111
  • 121
  • git commit says "nothing to commit". – trusktr Mar 18 '12 at 21:26
  • Are you on the master branch or another_branch while commiting? – rtn Mar 18 '12 at 21:27
  • I tried committing on both branches, they both say "nothing to commit". – trusktr Mar 18 '12 at 21:51
  • Well then you haven't added anything to commit. Remember when doing "git add ." you only add from current folder and downwards. – rtn Mar 18 '12 at 21:57
  • True, I see that I haven't added anything to commit, but why doesn't git merge changes when the branches are different (with no new commits in either branch)? I made a new question about this: http://stackoverflow.com/questions/9763443 – trusktr Mar 18 '12 at 23:58
  • 1
    The term "merge" essentially means "extract the changes between the tip and the root of the branch, and apply them to the destination" (it's a bit more complex in reality, but this would do as an explanation). If your branch contains no changes, then there is no change set to apply to the destination. It is the changes in the branch itself that defines the merge, not the difference between source and destination. – vhallac Mar 19 '12 at 06:15