Tag Archives: git

Who was my first parent? [Git]

A co-worker of mine had the following tree structure in his git repository and he wanted to get rid of the 2abaf35 and 607f016 commits. The solution is a simple

git reset --hard e5e67d0


But, for the sake of fun, I wanted to do it without referring to a SHA value. The HEAD commit has two parents e5e67d0 and 2abaf35. HEAD^ will refer to the first parent and HEAD^2 will refer to the second parent. But how do we know which parent is the first?

According to charon at #git on freenode, HEAD at the time of invoking the merge will always be the first parent. This is the left-most (straight line) branch. The remaining commits will be the remaining parents, in the order you specify. So, in this case,

git reset --hard HEAD^

would have achieved the same feat.

csh woes

One thing I hate about the C Shell is the lack of function support. You’re left with aliases but they don’t work out all the time.

The other I wanted to add the git branch you’re on to the csh (tcsh, in fact) prompt. I tried out adding the following to the .cshrc:

alias GIT_BRANCH_CMD "sh -c 'git branch --no-color 2> /dev/null' | sed -e '/^[^*]/d' -e 's/* (.*)/(1)/'"
alias cd 'chdir !*;set prompt=`whoami`@`hostname`": %~"`GIT_BRANCH_CMD`" > "'
cd ~

But it only works when you cd to the directory. Out of luck when you git checkout, etc. To my knowledge csh has no advantage over bash, so the lesson is to use bash whenever possible.

Using Git to track law changes

Hey look, it’s not just the code changes we can track with Git! Randomly came across this article from The H Open today. BundesGit uses Git to track changes in the German federal law. This is a pretty cool use for something that is intended to be a source code management system. Tracking something that may change every now and then, so you can keep track of what changed. Laws of a country, company policies, documentation; the possibilities are endless.