Chances are you're using Git at work, at home, and even in the kitchen. (Yes, it has become that popular.) And as ever more people use it, there is a lot of great content out there discussing it. In this week's editorial I want to share some of the things I found particularly interesting.
Customize Git to Your Needs
First off, every Git post is mandated by Linus himself to list a couple of awesome aliases the author thinks will enlighten their readers. Here are mine (straight from ~.gitconfig
):
[alias]
st = status --branch --short
wat = log --graph --decorate --oneline -15
cd = checkout
patch = add --patch
unstage = reset HEAD --
unstage-patch = reset HEAD --patch
com = commit -m
amend = commit --amend --no-edit
follow = log --follow -p
I use git st
to get a less cluttered version of the status and git wat
to see a colorful, tree-like, and diff-free log output that helps me remember where I was before taking the break. In fact, I use them so often that I have a bash alias g
that goes git st; echo ''; git wat -5
.
Next up is git cd
, which I created because I change branches quite often. Once I'm done making changes I try to convince the world I knew what I was doing, so I go through the files change by change with git patch
and create separate commits. If something gets staged that shouldn't have been, I use git unstage
and particularly git unstage-patch
to unstage - either all at once or, again, change by change.
Typing git commit -m
became too long, so I shortened it to git com
and because I often forget new files (git patch
doesn't list them) I created git amend
to amend the last commit with the newest changes.
Last on the list is git follow
, which shows you all changes pertaining to a particular file. Unfortunately I didn't find a way to just see the commits without the damn diffs because often times I don't care about them.
Of course I am not the only one with aliases to use and tips to give. Here are a few others:
If you work with GitHub a lot, you might be interested in getting Git to check out pull requests with something like git checkout pr/999
- here's how. And this tip allows you to clone git clone gh:<repo>
. (On a side note, in October GitHub accidentally exposed data from some private repositories - the incident report is quite interesting.)
A nice tool to visualize how a Git repo evolved over time is Git of Theseus. With it you can stack plots for total line count (right) or code line survival rates.
If you're interested in statistics like commits per author or per month or even to get a suggestion for a reviewer, give git quick statistics a try.
Usability
Continue reading %Git Better! Learn Aliases, Settings, Tools, Background%
by Nicolai Parlog via SitePoint
No comments:
Post a Comment