Another weird git problem

Lately whenever I have to rebase I get a weird error about how I have a dirty tree and need to commit files.


Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:

Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.

Well this is a dirty lie, and the problem appears to be related to hardlinking changing the ctime of the source file and confusing git into thinking that the files need to be re-checked-out. Bottom line, the fix is here:


git config --global core.trustctime false

Recent git branches

Sometimes I forget to delete my old git branches, and I forget which is what and who is how. And so on and so forth. So I do this!:


git reflog --date=local --all

This outputs a nifty list of all the recent commits and which branches they were too. w00t.

iOS timing

Again, do as I say not as I do. Here’s a quick thing I like to do:

NSTimeInterval start = CACurrentMediaTime();
[stuff...]
NSTimeInterval end = CACurrentMediaTime();
NSLog(@"%f", end-start);

git format-patch and git am

Occasionally I need to send a git patch between computers. Yes, I know there are more efficient ways of doing this, but occasionally it needs to happen. So here’s how I do it:

git format-patch --binary master.. --stdout > the.patch

and how to apply it:

git am --signoff < the.patch

Sigh, GoDaddy

Well, it’s official. All my domains are now registered with GoDaddy. Why? Because while they have a website which makes my eyes bleed, they constantly have coupons like OMGWTF FREE DOMAIN TRANSFERS for 5 years. So, I pay nothing.

I’ll revisit who to transfer my domains to in about 5 years. Any suggestions until then?

Increase the max number of processes

I ran into this problem earlier today. This will increase the number of processes at a time, above the default 256. w00t.


echo 'limit maxproc 2000 2000' | sudo tee -a /etc/launchd.conf
sudo reboot

Finally starting to get git, at 1% at least

I work on a project on both my desktop and laptop. Each one tracks remote origin, but sometimes I do work on my desktop and want to continue it on my laptop.

So, here goes. This might be totally bogus, but it appears to work. Maybe some git-gurus can improve?

Lets setup my laptop add my desktop as a remote

git remote add desktop ssh://desktop/path/to/repo

Now lets do some work on my desktop:

git checkout -t -b mybranch origin/master
... do some stuff ...
git commit

Then lets say on my laptop I want to continue that work.

git pull
git -t -b mybranch remotes/desktop/mybranch
... do some stuff ...
git commit
git push desktop

Woot, now I’ve done work on my laptop, and pushed it back to my desktop. All without pushing back to origin/master (which sometimes I do not want to do!)

macports: git-upload-pack: command not found

When doing a git clone from a repo hosted on a Mac OSX machine (installed using macports), I get this error on the client (Linux, cygwin, whatever):

git-upload-pack: command not found
Solution is to do this on the OSX machine:

cd /usr/bin
sudo ln -s /opt/local/bin/git* .

Blatently stolen from this guy: http://soniahamilton.wordpress.com/2009/11/19/macports-git-upload-pack-command-not-found/

Also, better git macports install

But with XCode 4, who needs it?


sudo port install git-core +svn +doc +bash_completion +gitweb

Git bash prompt

This is super useful:


export PS1="\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\`ruby -e \"print (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').gsub(/^\* (.+)$/, '(\1) ')\"\`\[\033[37m\]$\[\033[00m\] "

Stolen from here: http://asemanfar.com/Current-Git-Branch-in-Bash-Prompt

And this is even more useful! This shows the dirty non/dirty state too!


function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty)\)/"
}

export PS1="\[\033[38m\]\u@\h\[\033[01;34m\] \w \[\033[31m\]\$(parse_git_branch)\[\033[37m\]$\[\033[00m\] "

Stolen and modified from here: http://henrik.nyh.se/2008/12/git-dirty-prompt/