- @nicknovitski
- nicknovitski.com
- [email protected]
Always Rebase
ALWAYS REBASE
"Rebase words are uttered only by the rebase, and can for such at once be understood." -W.H. Auden
git rebase [upstream]
- All changes made by commits in the current branch which are not in [upstream] are saved to a temporary area.
- The current branch is reset to [upstream].
- The saved changes are reapplied to the current branch.
$ git push origin featurebranch
$ git reset --hard master
$ say yawn
$ git pull origin featurebranch
$ git checkout master
$ git pull origin master
$ git checkout feature/12345-actual-branch-name
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: added arkleseizure to gemfile
Applying: change sneeze specs to use arkleseizure
Applying: adding new backbone model and view
Applying: track sneezes
error: could not apply 07e9061...make javascript analytics event-driven
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' and run 'git rebase --continue'
Could not apply 07e9061...make javascript analytics event-driven
They are noise. You do not need them. Stop making more.
git rebase --interactive [the last commit you don't want to change]
git rebase -i
strongest subcommand there is
pick 52ee076 add commander to dependencies¬
pick e8c3194 add first version of bin command¬
pick 9852e66 separate card and set reporters¬
pick d2b069a have cli dynamically load version information¬
# Rebase dd601d9..d2b069a onto dd601d9¬
#¬
# Commands:¬
# p, pick = use commit¬
# r, reword = use commit, but edit the commit message¬
# e, edit = use commit, but stop for amending¬
# s, squash = use commit, but meld into previous commit¬
# f, fixup = like "squash", but discard this commit's log message¬
# x, exec = run command (the rest of the line) using shell¬
#¬
# If you remove a line here THAT COMMIT WILL BE LOST.¬
# However, if you remove everything, the rebase will be aborted.¬
#¬
The interactive mode is meant for this type of workflow:
1. have a wonderful idea
2. hack on the code
3. prepare a series for submission
4. submit
where point 2. consists of several instances of [either]
+ regular use
1. finish something worthy of a commit
2. commit
+ independent fixup
1. realize that something does not work
2. fix that
3. commit it"
If you remove a line here THAT COMMIT WILL BE LOST.
However, if you remove everything, the rebase will be aborted.
reword 9852e66 start a feature
squash d2b069a oh yeah add the specs
squash 52ee076 fix broken integration feature
squash e8c3194 no wait, change the feature to actually work
reword 52ee076 fix broken integration feature
squash e8c3194 no wait, remove it instead
reword d2b069a oh yeah add the specs
reword 9852e66 start a feature
edit d2b069a do something good, but also commit s3 keys
pick 52ee076 struggle with something difficult
reword e8c3194 [lurid frustration-fueled profanity]
"Faster than his tongue did make offence his -i did heal it up..." -W. Shakespeare