Git missed rebase for extended branch development?
A few months ago I branched off of the master development branch in a project I'm working on. I've been working on my own experiment branch, but constantly pulled in the changes from master to keep up to date. Every time I did that I used this command set
git checkout master
git pull
git checkout experiment
git merge master
Today I went to merge my experiment branch back into master. I simply made sure I was all up to date with master, and called
git checkout master
git merge experiment
When I look in GitX at the master branch, it shows a seperate line of development for what looks like every single time that I pulled from master to keep myself up to date. Is this because I should've been rebasing master when I pulled the chang开发者_如何学Goes?
Does anyone have a decent solution to fix this? I guess I could rebase experiment onto master? But experiment is quite the branch, and I'd like to keep it as an obvious seperate branch in history. Is there a way for me to go back and rebase the old problematic merges? I'm pretty new to git as you can probably tell.
Thanks!
Exactly.
When you are performing a merge, you are in fact having one commit that is having 2 parents, what is happening is like this:
original history:
A <- B <- C
you changed something (X and Y)
A <- B <- C <- X <- Y
you pulled from tracked repository (assuming someone added D and E)
A <- B <- C <- D <- E
^
\- X <- Y
and then you merged:
A <- B <- C <- D <- E <- M
^ /
\- X <- Y <-/
That's why you see those "separate lines"
In case of rebase, it is something like this:
you pulled from tracked repository (assuming someone added D and E)
A <- B <- C <- D <- E
^
\- X <- Y
You rebase (which means GIT applies your change X, Y again)
A <- B <- C <- D <- E <- X' <- Y'
(revision X and Y is abandoned)
which I believe is what you like to see
精彩评论