/dev/blah

things i want to remember, things i want to share

Développeur Python et adepte Linux depuis 2005, Core développeur Kivy, passionné par beaucoup trop de choses.
Profil Github gpg signature bitcoin address

Entries tagged “references”

Git resources + random tips

written by tshirtman, on 1/13/14 1:04 AM.

In the last few years, git has gained a lot of popularity in open source projects, howether, newcommers, and even seasoned contributors, often seems to struggle with its interface.

There is a simple reason to that, git has beautiful internals, but you don’t care about that, you want to use it, the issue is that its interface only make (some) sense (it’s not completly consistent) in the light of its beautiful internal model.

On top of that, the initial git documentation was, to say the least, indigest, technically correct, but not really helpful, again, because it explained how things worked, not how to use them.

Howether, a good number of resources have poped up while git was gaining popularity, here is my shortlist of favorite resource, in order of complexity, to get you accustomed with it.

git - the simple guide (i usually find this one by googling “git no deep shit”, easy to remember), this colorful guide can be read in 5-10 minutes, and will get you started, sure, it glosses over details, but it’s a good startpoint, and the format makes it easy to read.

git for 4 and up This video will show you how git works with toys and manual construction of commit trees (the famous DAG) it’s a great way to understand the model, and behavior of git, you’ll see it’s, in fact pretty simple.

think-like-a-git This one will use, and really deserve, one or two hours of your time, it’s not the best start point, but it will make things a lot clearer if you have been using git for some time and still feel uneasy when less-common situations, it’ll make clearer to you that, really, nothing is ever an unrecoverable mistake with git.

Pro Git Ok, this one is now more or less the official documentation, and i rarely go for it, but when you want a definite answer, or face a complex situation, it’s a really, really, complete resource, and it’s translated in a lot of languages, like even human languages, isn’t that great?

On top of that, i’ll add a few of my own tips:

-p flag

Look for the “-p” flag in commands, you can use it on add/commit/reset/stash and others, its exact behavior of course depend of the situation, but the general idea is that when you want to see/review each part of the change, it’s what you want. I basically never use “git add” without “-p”, this way i see exactly what i’m about to commit.

reflog

git reflog

this one will show you where you’ve been, regarding commit ids, recently, if you are lost after a rebase/reset/checkout, and just want to go back, it can save you a lot of trouble.

aliases

If you do something often, or if you don’t do it often enough to remember the right options, do an alias for it, here are a few of my most useful ones.

    st = status --short
    ci = commit
    co = checkout
    br = branch
    ll = log --graph --pretty=format:\"%C(yellow)%h %C(blue)%ci%C(green) %an %C(red)%d %Creset%s\"
    lla = log --graph --pretty=format:\"%C(yellow)%h %C(blue)%ci%C(green) %an %C(red)%d %Creset%s\" --all
    nopushed = log --branches --not --remotes --simplify-by-decoration --decorate --oneline
    nomerged = branch -a --no-merged
    latest = for-each-ref --sort=-committerdate --format='%(committerdate:short) %(refname:short) [%(committername)]'
    rc = rebase --continue

creating an alias is easy

git config --global alias.aliasname "some git command"

or you can just edit ~/.gitconfig

reset/checkout

Learn the difference! It can save your life^Wfile. ;) You should be comfortable with both pretty soon, they are very useful.

And ask questions, either to your local git guru, or on the ‘net, learn how they think about git, it’s not magical, it’s just a way to think, you just need to get the hang of it :).

Tip me if you like this :)

Tags

#FIXME 3G absurd ad_sense alterway aléatoire android animation anonymity atheism bach backlog bash bitcoins blog blogging boldness book books boulot bricolage bépo C canvas captcha captures carte SD censure christianity chroot CLI cli cloudwatt code colors comfort zone command line community company life conferences contest copwatch copwatchnord-idf core-devs cours ct705 culture deb debian debug deformation dehors dessin dev distribute distribution débutant déploiement développement ebooks eeepad eeepc effect ego empty en escher event firefly flappy bird flask fosdem foss fr fun game garden gdb geek culture git github goals graphics grrr gödel hack hackathon hacked hacking hooks i3 images IMAP inspirational install isync java jeu jeu video jinja2 jni keyboard keynav kivy kv lame learning lib libre life linux lol macosx magnet mail mailing-list mails maths mbsync meetings memory leak mesh meta mint mirroir MIT module motivational mouse museomix mutt nexus7 no-mouse notmuch nottoomuch offlineimap onycroit opencourseware osc packaging paris passphrase password patch pentacatyl people perte de données ping pip planning plugin positioning pr procrastination programmation progress project projet property proudhon proxy psf publisher/consumer pull-down pygame pyjnius pypi python pythonar qtile raid rapsberry pi reading recorder references release religion responsive review reviews réseau réseaux sociaux résurection salon screenshots script self service shows shutil shyness sizing solib sortie sousous!!! spam spritz stash status systeme système templating terminal texture texture coordinates Thomas Paine thread thème tiling time time management. tip tips tools transformer tutorial tv twitter typematrix typing ubuntu ubuntu-fr ultimate-smash-friends unity upload images useless usf utils value VDM video vie/mort vim virtualenv visite widget windows wm wmii work workflow workflow. zine études