Quantcast
Channel: buildengineer.org » git
Viewing all articles
Browse latest Browse all 7

Stupid git tricks

$
0
0

This is the first in an ongoing series of posts about basic and not so basic ways to use git. Many of these come from a wiki page I maintain at work, with the examples changed to use the git repository itself. (At work I use local examples.) Most if not all of this information is already available somewhere on the web — where do you think I learned it? — but some may appreciate my particular take on things. Or not.

Visualizing what’s going on

This is a question I get all the time:

• “How the bleepin’ bleep do I tell what’s what?!!?”

Use one of several graphical tools for git: gitk (comes with all git installs); qgit; or gitX (if you’re using a Mac); and many others. There’s even a sneaky way to do this in your terminal window:

$ git log --graph --pretty=oneline --abbrev-commit
*   1e63341 Merge branch 'maint'
|\
| * 8695353 Fix typo in pack-objects' usage
| * 8713feb Make sure that git_getpass() never returns NULL
| * dbda967 t0004 (unwritable files): simplify error handling
| * e14712c rev-list-options: clarify --parents and --children
* | 9855b08 Start 1.7.4 cycle
* |   b886656 Merge branch 'tr/send-email-refuse-sending-unedited-cover-letter'
|\ \
| * | a03bc5b send-email: Refuse to send cover-letter template subject
* | |   34289ec Merge branch 'ab/send-email-catfile'
|\ \ \
| * | | 89bf1ba send-email: use catfile() to concatenate files
* | | |   a27d5be Merge branch 'jc/grep-header-all-match-fix'
|\ \ \ \
| * | | | 5aaeb73 log --author: take union of multiple "author" requests
| * | | | 95ce9ce grep: move logic to compile header pattern into a separate helper
* | | | |   08986de Merge branch 'jc/no-branch-name-with-dash-at-front'
|\ \ \ \ \
| * | | | | 6348624 disallow branch names that start with a hyphen
| | |/ / /
| |/| | |
* | | | |   0ff4bdb Merge branch 'jn/gitweb-test-lib'
|\ \ \ \ \
| * | | | | 89d1b5b t/gitweb-lib.sh: Use tabs for indent consistently
| * | | | | b5d3450 t/gitweb-lib.sh: Use GIT_BUILD_DIR
* | | | | |   083dd39 Merge branch 'bc/fortran-userdiff'
|\ \ \ \ \ \
| * | | | | | 909a549 userdiff.c: add builtin fortran regex patterns
* | | | | | |   2a1be3f Merge branch 'jk/read-tree-empty'
|\ \ \ \ \ \ \
| * | | | | | | fb1bb96 read-tree: deprecate syntax without tree-ish args
* | | | | | | |   7fd739c Merge branch 'rr/format-patch-count-without-merges'
|\ \ \ \ \ \ \ \

(which looks really awesome in color…). You can make an alias for that in your global git config file:

$ git config --global alias.tree 'log --graph --pretty=oneline'

and then

git tree

will do this display for you.

Another handy tool that comes with git is git-gui, which is a Tcl/Tk application that lets you clone repos, create branches, etc. from a gui. Just type

git gui

and go to town. Here’s a brief illustration:

Illustration of git gui


Viewing all articles
Browse latest Browse all 7

Trending Articles