Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

hpr2573 :: Foundations of git rebase

Klaatu talks about git rebase

<< First, < Previous, Latest >>

Hosted by Klaatu on Wednesday 2018-06-13 is flagged as Clean and is released under a CC-BY-SA license.
Tags: git,rebase,merge.

Listen in ogg, spx, or mp3 format. | Comments (0)

Part of the series: Version Control

This is an open series in which Hacker Public Radio Listeners can share their knowledge and experience of version or revision control systems such as Bazaar, Mercurial, Subversion, CVS and Git.

A git rebase is like a git merge done through rose-coloured glasses.

You can see it for yourself by doing this little experiment. Assuming the alice directory is a valid git repository:

$ cd alice
$ echo "foo" >> rebase.episode
$ git add rebase.episode ; git commit -m 'begin rebase episode'
$ git checkout -b monsters

$ git branch
* monsters
$ echo "ghoul" >> ghoul.txt
$ git add ghoul.txt ; git commit -m 'ghoul'
$ git checkout master
$ echo "rogue" >> rogue.txt
$ git add rogue.txt ; git commit -m 'rogue'

$ git checkout monsters
$ echo "dragon" >> dragon.txt
$ git add dragon.txt ; git commit -m 'dragon'

$ git checkout master
$ echo "paladin" >> paladin.txt
$ git add paladin.txt ; git commit -m 'paladin'

You have now emulated a bunch of activity on two separate branches of a git repository. Create a copy of the repo so that you can perform two separate git actions.

$ cd ..
$ cp -r alice alice-merge
$ cp -r alice alice-base

Do an honest merge:

$ cd alice-merge
$ git checkout master
$ git merge monsters

The log shows you an accurate representation what got merged, and how all those changes came to be:

$ git log --oneline
123456 Merged monsters into master
789101 paladin
112131 dragon
415161 rogue
718191 ghoul
7ef217 begin rebase episode

Now perform a rebase.

$ cd ../alice-base
$ git checkout master
$ git rebase monsters

The log displays a different story than what really happened.

123456 Merged monsters into master
8e9122 paladin
21d163 rogue
912a3f dragon
51c098 ghoul
7ef217 begin rebase episode

Better? Worse? YOU DECIDE!

Show Transcript

Automatically generated using whisper

whisper --model tiny --language en hpr2573.wav

<< First, < Previous, Latest >>


Subscribe to the comments RSS feed.

<< First, < Previous, Latest >>

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?