Created
July 30, 2012 10:38
-
-
Save fingolfin/3206116 to your computer and use it in GitHub Desktop.
How to rebase TheSin's dpkg pull request
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add alias for TheSin's fink tree, and fetch it | |
git remote add TheSin https://github.com/TheSin-/fink | |
git fetch TheSin | |
# Setup local branch 'thesin-dpkg' to track TheSin's master branch | |
git co -b thesin-dpkg TheSin/master | |
# The first commit that modified @addlist in perlmod/Fink/Bootstrap.pm | |
# was commit 7b3cc78525. Thus we want to insert a commit *before* | |
# it that changes @addlist to span multiple lines. | |
# Therefore, we want to rebase interactively on the *grandparent*. | |
# This way, we will be able to insert something between the parent | |
# commit, and the commit self. | |
# | |
# The command below will open an editor (by default vi, else whatever | |
# you set EDITOR to. Nifty sidenote, I use this: | |
# export EDITOR="/usr/bin/bbedit --wait --resume") | |
# Aaanyway: The editor will show you a list of commits to edit. | |
# We want to edit the very first one: Change 'pick 04783a3' | |
# into 'e 04783a3', then save&close the file to proceed | |
git rebase -i 7b3cc78525^^ | |
# This will return you to the prompt, with the repository in the state | |
# *right after* the parent commit 04783a3 has been applied, but | |
# *before* commit 7b3cc78525 is going to be applied. In my setup, | |
# I also get this nice prompt, which indicates what I am doing: | |
# (thesin-dpkg|REBASE-i)$ | |
# See also <http://railstips.org/blog/archives/2009/02/02/bedazzle-your-bash-prompt-with-git-info/> | |
# So now let's edit perlmod/Fink/Bootstrap.pm in you favorite editor, | |
# changing the @addlist array so that each entry is on its own line. | |
# I did it so that it looked like this (note that last comma, put there | |
# as to further reduce further diffs; perl will just ignore it): | |
# my @addlist = ( | |
# "apt", | |
# ... | |
# "libgettext8-shlibs", | |
# ); | |
# | |
# Save your work, then commit it: | |
git add perlmod/Fink/Bootstrap.pm | |
git ci -m "Put each @addlist entry on its own line" | |
# Now we are going to let git re-apply the remaining commits. This will | |
# run into conflicts due to our new commit! But worry not, they will be | |
# easy to deal with | |
git rebase --continue | |
# OK, right the first commit gives a conflict ... of course. So let's | |
# edit perlmod/Fink/Bootstrap.pm again, and fix this. | |
# Then save, notify git that you resolve the conflict (via 'git add'), | |
# and continue the rebase (it'll prompt you to edit the commit message... | |
# to continue, just close the file it just opened with the commit msg) | |
git add perlmod/Fink/Bootstrap.pm | |
git rebase --continue | |
# This will repeat two more times: | |
# edit, add, continue | |
bbedit perlmod/Fink/Bootstrap.pm | |
git add perlmod/Fink/Bootstrap.pm | |
git rebase --continue | |
# edit, add, continue | |
bbedit perlmod/Fink/Bootstrap.pm | |
git add perlmod/Fink/Bootstrap.pm | |
git rebase --continue | |
# And that's it. You have arrived at a new branch, but with subtly changed history. | |
# For the record, I have pushed the result of what I did above here: | |
# <https://github.com/fingolfin/fink/tree/thesin-dpkg> | |
# Note that you will get different commit ids from those I got! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I get this when I try to push now
To https://github.com/TheSin-/fink.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/TheSin-/fink.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.