From f366552b44c469a9e6492f3f44b00a89f75b109e Mon Sep 17 00:00:00 2001 From: Ben Lynn Date: Fri, 7 Nov 2008 14:37:34 -0800 Subject: [PATCH] Minor edits. --- basic.txt | 12 ++++++++++-- grandmaster.txt | 4 +--- history.txt | 12 +++++++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/basic.txt b/basic.txt index 4c4262b..9447298 100644 --- a/basic.txt +++ b/basic.txt @@ -1,8 +1,10 @@ == Basic Tricks == Rather than diving into a sea of Git commands, use these elementary examples to -get your feet wet. Despite their simplicity, each of them are useful. In fact, -for many purposes you can get by with a handful of basic commands. +get your feet wet. Despite their simplicity, each of them are useful. + +In fact, when I first started using Git, for months I never went beyond the +commands in this chapter. === Saving State === @@ -147,3 +149,9 @@ Or since yesterday: Or between a particular version and 2 versions ago: $ git diff SHA1_HASH "@{2}" + +Instead of running log and diff directly, sometimes I'll browse history with +http://sourceforge.net/projects/qgit[qgit], due to its slick photogenic +interface, or http://jonas.nitro.dk/tig/[tig], a text-mode interface that works +well over slow connections. Alternatively, install a web server, run +*git instaweb* and fire up any web browser. diff --git a/grandmaster.txt b/grandmaster.txt index f1f691d..ca136c3 100644 --- a/grandmaster.txt +++ b/grandmaster.txt @@ -37,7 +37,7 @@ and others get your project via: === Commit What Changed === -Telling Git when you've added, deleted and renamed files gets tedious. Instead, you can type: +Telling Git when you've added, deleted and renamed files is troublesome for certain projects. Instead, you can type: $ git add . $ git add -u @@ -118,8 +118,6 @@ Eventually, you may want to run *git gc \--prune* to recover space. Be aware tha 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. -I like browsing history with http://sourceforge.net/projects/qgit[qgit], due to its slick photogenic interface, and http://jonas.nitro.dk/tig/[tig], a text-mode interface that works well over slow connections. - One easy trick is to use built-in git aliases shorten your most frequently used commands: diff --git a/history.txt b/history.txt index daeba0e..fa8305d 100644 --- a/history.txt +++ b/history.txt @@ -31,7 +31,7 @@ Want to include a few more edits in that last commit? Then make those edits and === ... And Then Some === -Let's suppose the previous problem is ten times worse. After a lengthy session you've made a bunch of commits. But you're not quite happy with the way they're organized, and some of those commit messages could use rewording. This is quite likely if you've been saving early and saving often. Then type +Let's suppose the previous problem is ten times worse. After a lengthy session you've made a bunch of commits. But you're not quite happy with the way they're organized, and some of those commit messages could use rewording. Then type: $ git rebase -i HEAD~10 @@ -48,10 +48,16 @@ Then: - Replace "pick" with "edit" to mark a commit for amending. - Replace "pick" with "squash" to merge a commit with the previous one. -Next run *git commit \--amend* if you marked a commit for editing. Otherwise, run: +If you marked a commit for editing, then run: + + $ git commit --amend + +Otherwise, run: $ git rebase --continue +So commit early and commit often: you can easily tidy up later with rebase. + === Local Changes Last === You're working on an active project. You make some local commits over time, and @@ -85,7 +91,7 @@ Afterwards, you must replace all clones of your project with your revised versio Want to migrate a project to Git? If it's managed with one of the more well-known systems, then chances are someone has already written a script to export the whole history to Git. -Otherwise, take a look at *git fast-import*. This command takes text input in a specific format and creates Git history from scratch. Typically a script is cobbled together and run once to feed this command, migrating the project in a single shot. +Otherwise, take a look at *git fast-import*. This command takes text input in a specific format and creates Git history from scratch. Typically a script is cobbled together and run once, migrating the project in a single shot. As an example, paste the following listing into temporary file, such as `/tmp/history`: ---------------------------------- -- 2.11.4.GIT