From 15f2b0182fbebdc5988c83deff8e776f794a21ea Mon Sep 17 00:00:00 2001 From: Ben Lynn Date: Tue, 18 Mar 2008 09:37:46 -0700 Subject: [PATCH] Aliases, printing current branch --- grandmaster.txt | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/grandmaster.txt b/grandmaster.txt index 5f0fd34..a2e0e92 100644 --- a/grandmaster.txt +++ b/grandmaster.txt @@ -95,10 +95,20 @@ then you sync with the official tree with a merge. This cycle repeats itself a f But now the history in your local Git clone is a messy jumble of your changes and the official changes. You'd prefer to see all your changes in one contiguous section, and after all the official changes. -This is a job for *git-rebase* as described above. +This is a job for *git-rebase* as described above. In many cases you can use +the *--onto* flag and avoid interaction. Also see the manpage for other amazing uses of this command, which really deserves a chapter of its own. You can split commits. You can even rearrange branches of a tree! +=== My Commit Is Too Big! === + +Have you neglected to commit for too long? Been coding furiously and forgotten +about source control until now? Made a series of unrelated changes, because +that's your style? + +No worries, use *git add -i* or *git commit -i* to interactively choose which +edits should belong to the next commit. + === Don't Lose Your HEAD === The HEAD tag is like a cursor that normally points at the latest commit, advancing with each new commit. Some Git commands let you move it. For example: @@ -133,4 +143,22 @@ Eventually, you may want to run git-gc to recover space. Be aware that doing so In true UNIX fashion, Git's design allows it to be easily used as a low-level component of other programs. There are GUI interfaces, web interfaces, alternative command-line interfaces, and perhaps soon you will have a script or two of your own that calls Git. -See http://git.or.cz/[the Git homepage] for some examples. +One easy trick is to use built-in git aliases shorten your most frequently used +commands: + + $ git config --global alias.co checkout + $ git config --global --get-regexp alias # display current aliases + alias.co checkout + $ git co foo # same as 'git checkout foo' + +Another is to print the current branch in the prompt, or window title. +Invoking + + $ git-symbolic-ref HEAD + +shows the current branch name. In practice, you most likely want to remove +the "refs/heads/" and ignore errors: + + $ git-symbolic-ref HEAD 2> /dev/null | cut -b 12- + +See http://git.or.cz/[the Git homepage] for more examples. -- 2.11.4.GIT