4

I have a git branch "dev". Branch "master" is reachable from dev. While on branch "dev", if I type "git log master..dev --pretty=oneline" it clearly shows that master is reachable (104 commits earlier). But if I type "git rebase master", it will stop with conflicts. Why is that? Shouldn't rebase have nothing to do in this case, since dev is already based on master?

The reason I am asking this is because I really want to do an interactive rebase with squashes and rewords to clean up a lengthy history. But I am put off by having to resolve all the conflicts that should have already been resolved once I start the rebase.

The following are some related questions that I've already looked at:

Community
  • 1
  • 1
Lawrence I. Siden
  • 9,191
  • 10
  • 43
  • 56
  • 1
    I think I see the problem now. In branch dev's history. There are many merges. Master is only one of them. So of course, when I want to rebase with master upstream, there are conflicts. I'll just merge with master again w/ --strategy "ours" (I'm the only programmer - so no one else is affected by anything I do). – Lawrence I. Siden Sep 19 '11 at 14:43

2 Answers2

1

git rebase master rebases your branch to be based off the latest commit in master. If you want to base it off something earlier, you need to specify the exact commit, i.e.

git rebase `git merge-base master HEAD`
Karl Bielefeldt
  • 47,314
  • 10
  • 60
  • 94
0

rebase != merge

If you just want to fast forward, use

git pull --ff-only ...
git merge --ff-only ...

If you want to 'automatically rebase/fastforward' depending on the current context and relationship of your branches, I suppose this would work:

git pull --rebase ...

You may want to read the man page on what it does, precisely

sehe
  • 374,641
  • 47
  • 450
  • 633