Eventually you’ll discover the Easter egg in Git: all meaningful
operations can be expressed in terms of the rebase command. Once
you figure that out it all makes sense.
Linus Torvalds
A---B---C topic
/
D---E master
A---B---C topic
/
D---E---F---G master
$ git rebase --onto master topic
A'--B'--C' topic
/
D---E---F---G master
D---E---F---G--A'--B'--C' topic
It can get more complex...
o---o---o---o---o master
\
o---o---o---o---o next
o---o---o---o---o master
\
o---o---o---o---o next
\
o---o---o topic
$ git rebase --onto master next topic
o---o---o---o---o master
| \
| o'--o'--o' topic
\
o---o---o---o---o next
Rebase only topic branches!
Rebasing (or any other form of rewriting) a branch that others
have based work on is a bad idea: anyone downstream of it is
forced to manually fix their history.
git-rebase --help
As an idea, squish your commits into one.
This will tidy up the history.
I know what you're thinking...
History? You know how many bugs we have?
Nobody cares about the fucking history!
History is for noobz! Pwnd!
Thats why I'm gonna show you this cool exec trick!
pick deadbee Implement feature XXX
fixup f1a5c00 Fix to feature XXX
exec make
pick c0ffeee The oneline of the next commit
edit deadbab The oneline of the commit after
exec cd subdir; make test
Like managing your local branches was easy...
A---B---C topic
/
D---E master (me)
D---E---F---H master (you)
A---B---C topic
/
D---E---F---H master (me)
A---B---C topic
/ \
D---E-----------P master (me)
D---E---F---H master (you)
A---B---C topic
/ \
D---E-----------P---M master (me)
\ /
F---H-------
Oh, git-pull merges branches.
A---B---C topic
/ \
D---E-----------P master (me)
D---E---F---H master (you)
$ git pull you master --rebase
A---B---C topic
/ \
D---E-----------P---F'--H' master (me)
That's why you don't create PR's from master to master.
A---B---C topic
/ \
D---E-----------P master (me)
A---B---C topic
/ \
D---E-----------P---H master (you)
$ git pull you master --no-ff
A---B---C topic
/ \
D---E-----------P---H---M master (me)