diff --git a/basic/index.html b/basic/index.html index 9c6e8f6..9a2f3d3 100644 --- a/basic/index.html +++ b/basic/index.html @@ -140,8 +140,8 @@ layout: reference
As you saw in the git add
section, in order to see what the
status of your staging area is compared to the code in your working
- directory, you can run the git status
command. I demonstrated
- using it with the -s
option, which gives you short output.
+ directory, you can run the git status
command. Using the
+ -s
option will give you short output.
Without that flag, the git status
command will give you more
context and hints. Here is the same status output with and without the
-s
. The short output looks like this:
@@ -572,7 +572,7 @@ Further paragraphs come after blank lines.
Notice how if you don't stage any changes and then run
git commit
, Git will simply give you the output of the
git status
command, reminding you that nothing is staged.
- I've highlighted the important part of that message, saying that nothing
+ The important part of that message has been highlighted, saying that nothing
is added to be committed. If you use -a
, it will add and
commit everything at once.
git reset
is probably the most confusing command written
- by humans. I've been using Git for years, even wrote a book on it and I
- still get confused by what it is going to do at times. So, I'll just
- tell you the three specific invocations of it that are generally
- helpful and ask you to blindly use it as I do - because it can be
- very useful.
+ by humans, but it can be very useful when you get the hang of it.
+ There are three specific invocations of it that are generally
+ helpful.
In the first case, we can use it to unstage something that you have +
First, you can use it to unstage something that has been
accidentally staged. Let's say that you have modified two files and want
to record them into two different commits. You should stage and commit
one, then stage and commit the other. If you accidentally stage both of
them, how do you un-stage one? You do it with
- git reset HEAD -- file
. Technically here you don't have to
+ git reset HEAD -- file
. Technically you don't have to
add the --
- it is used to tell Git when you have stopped
listing options and are now listing file paths, but it's probably good to
get into the habit of using it to separate options from paths even if you
don't need to.
So, let's see what it looks like to unstage something. Here we have +
Let's see what it looks like to unstage something. Here we have two files that have been modified since our last commit. We will stage both, then unstage one of them.
@@ -782,7 +780,7 @@ nothing to commit (working directory clean)git rm
will remove entries from the staging area.
This is a bit different from git reset HEAD
which "unstages"
- files. By "unstage" I mean it reverts the staging area to what was
+ files. To "unstage" means it reverts the staging area to what was
there before we started modifying things. git rm
on the
other hand just kicks the file off the stage entirely, so that it's not
included in the next commit snapshot, thereby effectively deleting it.
- I personally don't use this command that much in it's normal form - to
- delete files. It's often easier to just remove the files off your disk and
- then run a git commit -a
, which will automatically remove them
- from your index, too.
git commit -a
, which will also automatically remove
+ them from your index.
In a nutshell, diff --git a/branching/index.html b/branching/index.html index 6bea373..9b2434d 100644 --- a/branching/index.html +++ b/branching/index.html @@ -10,7 +10,7 @@ layout: reference Branching and Merging
Branching in Git is one of my favorite features. If you have used other +
Branching in Git is one of its many great features. If you have used other version control systems, it's probably helpful to forget most of what you think about branches - in fact, it may be more helpful to think of them practically as contexts since that is how you will most often be @@ -319,7 +319,7 @@ HelloWorld.hello
So first we're going to create a new branch named 'change_class' and - switch to it so your class renaming changes are isolated. I'm going to + switch to it so your class renaming changes are isolated. We're going to change each instance of 'HelloWorld' to 'HiWorld'.
@@ -333,9 +333,9 @@ class HiWorld 1 files changed, 2 insertions(+), 4 deletions(-)-
So now I've committed the class renaming changes to the 'change_class' - branch. If I now switch back to the 'master' branch my class name will - revert to what it was before I switched branches. Here I can change +
So now we've committed the class renaming changes to the 'change_class'
+ branch. To switch back to the 'master' branch the class name will
+ revert to what it was before we switched branches. Here we can change
something different (in this case the printed output) and at the same
time rename the file from hello.rb
to ruby.rb
.
Now those changes are recorded in my 'master' branch. Notice that the - class name is back to 'HelloWorld', not 'HiWorld'. Now I want to - incorporate the 'HiWorld' change so I can just merge in my 'change_class' - branch. However, I've changed the name of the file since I branched, +
Now those changes are recorded in the 'master' branch. Notice that the + class name is back to 'HelloWorld', not 'HiWorld'. To incorporate + the 'HiWorld' change we can just merge in the 'change_class' + branch. However, the name of the file has changed since we branched, what will Git do?
@@ -391,7 +391,7 @@ end HiWorld.hello-
Well, it will just figure it out. Notice that I had no merge conflicts +
Well, it will just figure it out. Notice that there are no merge conflicts and the file that had been renamed now has the 'HiWorld' class name change that was done in the other branch. Pretty cool.
@@ -474,9 +474,9 @@ index 9103e27,69cad1a..0000000A cool tip in doing merge conflict resolution in Git is that if you
run git diff
, it will show you both sides of the conflict
- and how you've resolved it as I've shown here. Now it's time to mark
+ and how you've resolved it as shown here. Now it's time to mark
the file as resolved. In Git we do that with git add
-
- to tell Git the file has been resolved, you have to stage it.
$ git status -s @@ -684,7 +684,7 @@ b7ae93b added from ruby
This way, it's pretty easy to see that we have Haskell code included in
- the branch (as I've highlighted). What is even cooler is that we can
+ the branch (highlighted in the output). What is even cooler is that we can
easily tell Git that we only are interested in the commits that are
reachable in one branch that are not reachable in another, in other words
which commits are unique to a branch in comparison to another.
@@ -751,7 +751,7 @@ ab5ab4c added erlang
tag", which allows you to add a tag message to it, which is what you almost
always want to do. Running this without the -a
works too, but
it doesn't record when it was tagged, who tagged it, or let you add a tag
- message. I would recommend always creating annotated tags.
$ git tag -a v1.0 diff --git a/index.html b/index.html index 35d07e5..a33d1d0 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ layout: referenceIntroduction to the Git Reference
- This is the Git reference site. This is meant to be a quick + This is the Git reference site. It is meant to be a quick reference for learning and remembering the most important and commonly used Git commands. The commands are organized into sections of the type of operation you may be trying to do, and @@ -28,7 +28,7 @@ layout: reference
How to Think Like Git
- The first thing that is important to understand about Git is + The first important thing to understand about Git is that it thinks about version control very differently than Subversion or Perforce or whatever SCM you may be used to. It is often easier to learn Git by trying to forget your assumptions diff --git a/inspect/index.html b/inspect/index.html index dcf86f3..cbf46f4 100644 --- a/inspect/index.html +++ b/inspect/index.html @@ -57,8 +57,8 @@ layout: reference you can use the
@@ -78,11 +78,11 @@ b532581 make "git unpack-file" a built-in--author
option. For example, let's say we're looking for the commits in the Git source code done by Linus. We would type something likegit log --author=Linus
. The search is - case sensitive and also will search the email address. I'll do the - example using the-[number]
option, which will limit the + case sensitive and will also search the email address. The following + example will use the-[number]
option, which will limit the results to the last [number] commits.If you want to specify a date range that you're interested in filtering your - commits down to, you can use a number of options - I use
--since
- and--before
, but you can also use--until
and ---after
. For example, if I wanted to see all the commits in - the Git project before 3 weeks ago but after April 18th, I could run this - (I'm also going to use--no-merges
to remove merge commits): + commits down to, you can use a number of options such as--since
+ and--before
, or you can also use--until
and +--after
. For example, to see all the commits in + the Git project before three weeks ago but after April 18th, you could run this + (We're also going to use--no-merges
to remove merge commits):@@ -105,9 +105,9 @@ b6c8d2d Documentation/remote-helpers: Add invocation sectionYou may also want to look for commits with a certain phrase in the commit - message. You can use
@@ -132,11 +132,11 @@ Date: Wed Mar 12 19:03:24 2008 -0500 arguments. If you want to use--grep
for that. Let's say I knew there + message. Use--grep
for that. Let's say there was a commit that dealt with using the P4EDITOR environment variable and - I wanted to remember what that change looked like - I could find the commit + you wanted to remember what that change looked like - you could find the commit with--grep
.--grep
and--author
to see commits that were authored by someone AND have a specific message content, you have to add the--all-match
option. In these - examples, I'm going to use the--format
option, so we can see + examples we're going to use the--format
option, so we can see who the author of each commit was. -If I look for the commit messages with 'p4 depo' in them, I get these +
If we look for the commit messages with 'p4 depo' in them, we get these three commits:
@@ -146,8 +146,8 @@ da4a660 Benjamin Sergeant git-p4 fails when cloning a p4 depo. 1cd5738 Simon Hausmann Make incremental imports easier to use by storing the p4 d-If I add a
--author=Hausmann
argument, instead of further - filtering it down to the one commit by Simon, it instead will show me all +If we add a
--author=Hausmann
argument, instead of further + filtering it down to the one commit by Simon, it instead will show all commits by Simon OR commits with "p4 depo" in the message:@@ -167,7 +167,7 @@ e96e400 Simon Hausmann git-p4: Fix submit user-interface. ...-However, if I add a
--all-match
, I get the results I'm +However, adding
--all-match
will get the results you're looking for:@@ -417,7 +417,7 @@ index bb86f00..192151c 100644-That's what we're looking for, but we don't want to have to figure out what commit the two branches diverged from every time. Luckily, Git has a - shortcut for this. If you run
@@ -438,7 +438,7 @@ index bb86f00..192151c 100644 the triple-dot syntax, because it will almost always give you what you want. -git diff master...erlang
(with + shortcut for this. If you rungit diff master...erlang
(with three dots in between the branch names), Git will automatically figure out what the common commit (otherwise known as the "merge base") of the two commit is and do the diff off of that.As a bit of an aside, you can also have git manually calculate the +
As a bit of an aside, you can also have Git manually calculate what the merge-base (first common ancestor commit) of any two commits would be with the
@@ -447,7 +447,7 @@ index bb86f00..192151c 100644 8d585ea6faf99facd39b55d6f6a3b3f481ad0d3dgit merge-base
command:So, you can do the equivalent of
git diff master...erlang
+You can do the equivalent of
git diff master...erlang
by running this:@@ -457,7 +457,7 @@ index bb86f00..192151c 100644 2 files changed, 9 insertions(+), 0 deletions(-)-I would of course recommend using the easier syntax, though.
+You may prefer using the easier syntax though.
diff --git a/remotes/index.html b/remotes/index.html index e9d75ff..3023bc8 100644 --- a/remotes/index.html +++ b/remotes/index.html @@ -100,7 +100,7 @@ origin git@github.com:github/git-reference.git (push) adds
[url]
under a local remote named[alias]
.For example, if we want to share our Hello World program with the world, - we can create a new repository on a server (I'll use GitHub as an example), + we can create a new repository on a server (Using GitHub as an example), which should give you a URL, in this case "git@github.com:schacon/hw.git". To add that to our project so we can push to it and fetch updates from it we would do this:
@@ -117,8 +117,8 @@ github git@github.com:schacon/hw.git (push) has no special meaning but is widely used becausegit init
sets it up by default, 'origin' is often used as a remote name becausegit clone
sets it up by default as the cloned-from URL. In - this case I've decided to name my remote 'github', but I could have really - named it just about anything. + this case we'll name the remote 'github', but you could name it just + about anything.@@ -266,10 +266,10 @@ fatal: No such remote 'guhflub'
The second command that will fetch down new data from a remote server is
@@ -277,9 +277,9 @@ fatal: No such remote 'guhflub' would first rungit pull
. This command will basically run agit fetch
immediately followed by agit merge
of the branch on that remote - that is tracked by whatever branch you are currently in. I personally don't much - like this command - I prefer runningfetch
andmerge
- separately. Less magic, less problems. However, if you like this idea, you - can read about it in more detail in the + that is tracked by whatever branch you are currently in. Running the +fetch
andmerge
commands separately involves less magic + and less problems, but if you like the idea ofpull
, you can + read about it in more detail in the official docs.git fetch [alias]
to tell Git to fetch down all the data it has that you do not, then you would rungit merge [alias]/[branch]
to merge into your current branch anything new you see on the server - (like if someone else has pushed in the meantime). So, if I were working on my - Hello World project with several other people and I wanted to bring in any changes - that had been pushed since I last connected, I would do something like this: + (like if someone else has pushed in the meantime). So, if you were working on a + Hello World project with several other people and wanted to bring in any changes + that had been pushed since we last connected, we would do something like this:$ git fetch github @@ -296,17 +296,17 @@ From github.com:schacon/hw * [new branch] lisp -> github/lisp-I can see that since the last time I synchronized with this remote, five branches +
Here we can see that since we last synchronized with this remote, five branches have been added or updated. The 'ada' and 'lisp' branches are new, where the - 'master', 'c-langs' and 'java' branches have been updated. In this case, my team - is pushing proposed updates to remote branches for review before they're merged - into 'master'. + 'master', 'c-langs' and 'java' branches have been updated. In our example case, + other developers are pushing proposed updates to remote branches for review before + they're merged into 'master'.
You can see the mapping that Git makes. The 'master' branch on the remote - repository becomes a branch named 'github/master' locally. That way now I can - merge the 'master' branch on that remote into my local 'master' branch by running -
git merge github/master
. Or, I can see what new commits are on that + repository becomes a branch named 'github/master' locally. That way you can + merge the 'master' branch on that remote into the local 'master' branch by running +git merge github/master
. Or, you can see what new commits are on that branch by runninggit log github/master ^master
. If your remote is named 'origin' it would beorigin/master
instead. Almost any command you would run using local branches you can use remote branches with too. @@ -356,10 +356,10 @@ To git@github.com:schacon/hw.gitPretty easy. Now if someone clones that repository they will get exactly - what I have committed and all of its history.
+ what we have committed and all of its history. -What if I have a topic branch like the 'erlang' branch we created earlier - and I just want to share that? You can just push that branch instead.
+What if you have a topic branch like the 'erlang' branch created earlier + and want to share just that? You can just push that branch instead.
$ git push github erlang