Home
Infinite Monkeys - Stupid git
October 2009
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Tue, Jun. 16th, 2009 04:51 pm
Stupid git

These are the things I know I know, these are things I know. Except maybe I don't know them correctly.

  • Added something to the index and want to get it out? git reset FILE. There's also git rm --cached FILE which maybe does something similar, but maybe not. Let's not tempt fate, eh?

  • git fetch seems quite temperamental, but git pull origin seems to do what I want every time. No complaining about the other end hanging up or other weird stuff.

  • Similarly git push origin master gets my changes up to our bare repository.

  • Don't make the mistake of git pull git://REPO/DIR into your local when you really wanted a git pull origin, it makes things very messy. And whatever you do, don't do that into a non-master branch, it makes things very confused.

  • While you might think git stash in a branch, switching branches, making changes, stashing that, then switching back and unstashing does the right thing, it doesn't. Make sure you specify the specific stash you want when you do your git stash apply lest you suddenly get very confused as the other branch's stashed changes get merged and resolved into the wrong branch. I think the stash list is a stack. Pretty sure.

  • git stash show -p is useful for looking at that patch you just stashed.

  • You can't always trust the refresh of gitk, sometimes it just doesn't seem to know what's going on.

  • Remember that git is state-ful, not transactional. If some previous command wrote some weird shit into your DIR/.git then git may think it's in some weird state from command to command that you don't know how to get out of.

  • While git bisect is super-cool, it gets more complicated when you realize not all of your discrete changes build correctly.

  • Some times it's easiest to just git diff -u > /tmp/BRANCH.patch, walk away from things with a fresh clone, and then reapply the patch (unlike Perforce, git diffs apply cleanly). You can preserve your old repo dir if you really feel like it.


Just getting this down so I don't forget it all.

CommentReplyAdd to MemoriesTell a Friend