Hacker News new | past | comments | ask | show | jobs | submit login
A few of my Git tricks, tips and workflows (nuclearsquid.com)
149 points by fogus on April 4, 2011 | hide | past | favorite | 19 comments

The best thing I did to help me get into using git was set up some aliases, to make it at least pretend it was like Mercurial and only needed the bare minimum number of characters to complete a command (in ~/.gitconfig):

  	st = status
  	d = diff
  	ci = commit
  	sh = stash
  	co = checkout
  	ps = push
  	pl = pull
  	cp = cherry-pick

I'd find cp much too unintuitive as an abbreviation for cherry-pick to use; less so but likewise with sh for stash.

I like the aliases at http://ruderich.org/simon/config/gitconfig though I'd call "fsck --strict --full" fsf.

There was an SO qn: http://stackoverflow.com/questions/267761/what-does-your-git...

`cp` for `cherry-pick` fits how I think about git and cherry-picking -- I'm copying a patch from one branch into another, aren't I?

Maybe "cpc" for "copy cherry" then?

I alias `cherry-pick` to `chp`.

git-sh is a pretty cool script for this sort of thing (although not aimed at similarity to mercurial): https://github.com/rtomayko/git-sh

My favorite Git tip is easygit (eg). It's training wheels wrapper for git. You use real git commands, but easygit has safer defaults and extra sanity checks (like forgetting to stage modified files). The help messages are more verbose and use more consistent terminology than git's man pages. For example, easygit always uses the term "staged" instead of "index/staged/add/hard/soft/mixed/cached/HEAD/etc."


I like the simplicity of this blog, not to mention the quality of this guide. I will definitely be taking a look at including some of these into my workflow. Thanks for this.

I wrote a tool, git-number[1], that allows me to use numbers when specifying file or directory names to any git operation.

I never have to resort to tab-completion ever since.

[1] https://github.com/holygeek/git-number

Looks pretty interesting. I usually use git add --interactive to accomplish most of this. Or just use tmux to copy the whole filename.

Very comprehensive article. While some of the stuff is well known by now, I'm sure there's something new in there for anybody. Very good find, OP

Why is the solution for Git completion in Zsh to just load the Bash completion? There is native Zsh completion for Git.

Thanks, I've updated the post to include this info.

I'll add that you can download the git completion functions if needed from http://zsh.cvs.sourceforge.net/viewvc/*checkout*/zsh/zsh/Com...

Related discussion for git workflow/branching


for windows folks smartgit is really good client. Am using old version where all features were free and not restricted to 30 day period.

very solid, although I'd like to see some hook scripts to get some ideas of what can be done there

I've got a few hook scripts in my dotfiles here: https://github.com/cypher/dotfiles/tree/master/git-hooks

But you can also take a look at the `.git/hooks/` directory in any git repo, it includes a lot of sample hooks.

thanks for the tip!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact