Search code examples
gitmergegit-svn

Why doesn't git know I merged? Is there a way to tell it?


I'm using git-svn; I typically create a topic branch, make commits to it, then checkout master, git svn rebase, git merge --squash topic_branch, git commit -m "summary comment", then git svn dcommit.

That works fine, but git doesn't seem to know I merged the branch changes into master. I tried this without svn involved:

# Make a repository, add a couple files
$ mkdir gittest
$ cd gittest
$ git init
$ touch foo bar
$ git add .
$ git commit -m "initial version"

# Make a branch, change a file, commit.
$ git checkout -b a_branch
$ vi foo # make a change
$ git commit -am "a change"

# Merge changes into master
$ git checkout master
$ git merge --squash a_branch
$ git commit -m "merged a_branch"

and gitk --all shows this, which would indicate that it's not a git-svn problem:

gitk picture showing apparently unmerged branch
(source: selfamusementpark.com)

In my main (git-svn) project, I see some changes early on that do appear to have been merged, but I don't know what I'm doing differently now that I didn't do then. (This is git 1.6.0.4 on Ubuntu Jaunty, if that matters.)


Solution

  • I think it's because you used --squash. I'm not sure why you did, but you shouldn't need to. From the --squash documentation for git merge:

    Produce the working tree and index state as if a real merge happened, but do not actually make a commit or move the HEAD, nor record $GIT_DIR/MERGE_HEAD to cause the next git commit command to create a merge commit. This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).

    Basically, you need to do a "proper" merge. Squashing seems to have a rather specific usage situation (one that I've never had, so I can't really comment on why it's useful). I guess it's if you don't want the branch tree to look messy if you did some work in a branch but then decided to just merge it into a different branch that you're doing more overarching work in.