Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Commit

Permalink
Merge pull request #191 from gvwilson/incorporating-wking-edits
Browse files Browse the repository at this point in the history
Incorporating many of @wking's changes (but not all); still unsure what to say about `-u`
  • Loading branch information
Greg Wilson committed Dec 7, 2013
2 parents 135c2cd + 75a2cf6 commit 6736926
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 42 deletions.
31 changes: 17 additions & 14 deletions git/novice/01-backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ title: A Better Kind of Backup
level: novice
---
The first time we use Git on a new machine,
we need to run a commands to configure a few things:
we need to configure a few things:

```
$ git config --global user.name "Vlad Dracula"
Expand Down Expand Up @@ -42,7 +42,7 @@ $ cd planets
and tell Git to make it a [repository](../gloss.html#repository):

```
$ git init .
$ git init
```

If we use `ls` to show the directory's contents,
Expand Down Expand Up @@ -102,9 +102,9 @@ $ git status
nothing added to commit but untracked files present (use "git add" to track)
```

The message "untracked files" means that there's a file in the directory
The "untracked files" message means that there's a file in the directory
that Git isn't keeping track of.
We can tell it that it should like this:
We can tell Git that it should do so like this:

```
$ git add mars.txt
Expand All @@ -125,7 +125,7 @@ $ git status
#
```

Git now knows that it's supposed to keep tack of this file,
Git now knows that it's supposed to keep track of this file,
but it hasn't yet recorded any changes for posterity.
To get it to do that,
we need to run one more command:
Expand All @@ -143,6 +143,10 @@ and stores a copy permanently inside the special `.git` directory.
This permanent copy is called a [revision](../../gloss.html#revision).
We use the `-m` flag (for "message")
to record a comment that will help us remember later on what we did and why.
If we just run `git commit` without the `-m` option,
Git will launch `nano` (or whatever other editor we configured at the start)
so that we can write a longer message.

If we run `git status` now:

```
Expand All @@ -164,8 +168,7 @@ Date: Thu Aug 22 09:51:46 2013 -0400
Starting to think about Mars
```

Now suppose Dracula adds more information to the file
(remember, `>>` appends rather than overwriting):
Now suppose Dracula adds more information to the file:

```
$ nano mars.txt
Expand Down Expand Up @@ -211,20 +214,20 @@ index df0654a..315bf3a 100644
+The two moons may be a problem for Wolfman
```

The output is cryptic because it isn't really intended for human beings to read:
it's a series of commands for tools like editors and `patch`
The output is cryptic because
it is actually a series of commands for tools like editors and `patch`
telling them how to reconstruct one file given the other.
If we can break it down into pieces:

1. The first line tells us that Git is using the Unix `diff` command
to compare the old and new versions of the file.
2. The second line tells exactly which versions of the file it is comparing;
we'll look in a moment at what `df0654a` and `315bf3a` mean.
2. The second line tells exactly which [revisions](../../gloss.html#revision) of the file
Git is comparing;
`df0654a` and `315bf3a` are unique computer-generated labels for those revisions.
3. The remaining lines show us the actual differences
and the lines on which they occur.
The numbers between the `@@` markers tell editors which lines we're changing,
and if you look in the left margin below them,
you'll see the line we are adding marked with a '+'.
The numbers between the `@@` markers indicate which lines we're changing;
the `+` on the lines below show that we are adding lines.

Let's commit our change:

Expand Down
30 changes: 16 additions & 14 deletions git/novice/02-collab.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ level: novice
Version control really comes into its own
when we begin to collaborate with other people.
We already have most of the machinery we need to do this;
the only thing missing is to move files
from one repository to another.
the only thing missing is to copy changes from one repository to another.

Systems like Git and Mercurial allow us to move work between any two repositories.
In practice,
Expand Down Expand Up @@ -38,7 +37,7 @@ $ cd planets
$ git init
```

Our local repository still contains the files `mars.txt` that we wrote earlier,
Our local repository still contains our earlier work on `mars.txt`,
but the remote repository on GitHub doesn't contain any files yet:

<img src="img/git-freshly-made-github-repo.svg" alt="Freshly-Made GitHub Repository" />
Expand All @@ -52,9 +51,10 @@ the string we need to identify it:
<img src="img/github-find-repo-string.png" alt="Where to Find Repository URL on GitHub" />

For now,
we'll use the 'http' identifier,
we'll use the 'http' [protocol](../../gloss.html#protocol)
(which is also used by web browsers)
since it requires the least setup.
Copy that string from the browser,
Copy that URL from the browser,
go into the local `planets` repository,
and run this command:

Expand All @@ -78,13 +78,13 @@ this command will push the changes from our local repository
to the repository on GitHub:

```
$ git push -u origin master
$ git push origin master
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (9/9), 821 bytes, done.
Total 9 (delta 2), reused 0 (delta 0)
To https://github.com/gvwilson/planets
To https://github.com/vlad/planets
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
```
Expand All @@ -93,6 +93,13 @@ Our local and remote repositories are now in this state:

<img src="img/github-repo-after-first-push.svg" alt="GitHub Repository After First Push" />

> ### The '-u' Flag
>
> You may see a `-u` option used with `git push`.
> This tells Git what [branch](../../gloss.html#branch) to use
> in the repository you're pushing to.
> We discuss branches and branching in our intermediate-level lessons.
We can pull changes from the remote repository to the local one as well:

```
Expand Down Expand Up @@ -145,15 +152,10 @@ Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 306 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/gvwilson/planets.git
To https://github.com/vlad/planets.git
9272da5..29aba7c master -> master
```

Notice that we *didn't* use the `-u` flag to `git push`:
the origin repository (the one on GitHub) already knows what `master` means.
We discuss this in a lot more detail in our intermediate lesson
when we talk about branching.

Our three repositories now look like this:

<img src="img/git-after-change-to-duplicate-repo.svg" alt="After Pushing Change from Duplicate Repository" />
Expand All @@ -167,7 +169,7 @@ remote: Counting objects: 4, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 3 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://github.com/gvwilson/planets
From https://github.com/vlad/planets
* branch master -> FETCH_HEAD
Updating 9272da5..29aba7c
Fast-forward
Expand Down
12 changes: 6 additions & 6 deletions git/novice/03-conflict.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 352 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://github.com/gvwilson/planets
To https://github.com/vlad/planets
29aba7c..dabb4c8 master -> master
```

Expand Down Expand Up @@ -87,9 +87,9 @@ but Git won't let us push it to GitHub:

```
$ git push origin master
To https://github.com/gvwilson/planets.git
To https://github.com/vlad/planets.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/gvwilson/planets.git'
error: failed to push some refs to 'https://github.com/vlad/planets.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
Expand All @@ -109,7 +109,7 @@ remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 3 (delta 1)
Unpacking objects: 100% (3/3), done.
From https://github.com/gvwilson/planets
From https://github.com/vlad/planets
* branch master -> FETCH_HEAD
Auto-merging mars.txt
CONFLICT (content): Merge conflict in mars.txt
Expand Down Expand Up @@ -188,7 +188,7 @@ Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 697 bytes, done.
Total 6 (delta 2), reused 0 (delta 0)
To https://github.com/gvwilson/planets.git
To https://github.com/vlad/planets.git
dabb4c8..2abf2b1 master -> master
```

Expand All @@ -207,7 +207,7 @@ remote: Counting objects: 10, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 2), reused 6 (delta 2)
Unpacking objects: 100% (6/6), done.
From https://github.com/gvwilson/planets
From https://github.com/vlad/planets
* branch master -> FETCH_HEAD
Updating dabb4c8..2abf2b1
Fast-forward
Expand Down
4 changes: 2 additions & 2 deletions git/novice/04-open.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,11 @@ not least because it gives them fewer passwords to remember.
However,
all of these services place some constraints on people's work.
In particular,
they give users a choice:
most give users a choice:
if they're willing to share their work with others,
it will be hosted for free,
but if they want privacy,
they have to pay.
they may have to pay.
Sharing might seem like the only valid choice for science,
but many institutions may not allow researchers to do this,
either because they want to protect future patent applications
Expand Down
8 changes: 4 additions & 4 deletions git/novice/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Set global configuration (only needs to be done once per machine):
git config --global color.ui "auto"
git config --global core.editor "your_editor"

Initialize a directory as a repository:
Initialize the current working directory as a repository:

git init .
git init

Display the status of the repository:

Expand All @@ -23,9 +23,9 @@ Add specific files to the staging area:

git add filename_1 filename_2

Add all modified files to the staging area:
Add all modified files in the current directory and its sub-directories to the staging area:

git add -A
git add -A .

Commit changes in the staging area to the repository's history:
(Without `-m` and a message, this command runs a text editor.)
Expand Down
4 changes: 2 additions & 2 deletions lessons/swc-git/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ $ cd planets
and tell Git to initialize it:

```
$ git init .
$ git init
```

If we use `ls` to show the directory's contents,
Expand Down Expand Up @@ -707,7 +707,7 @@ Let's add and commit those changes
(the `-A` flag to `git add` means "add everything"):

```
$ git add -A
$ git add -A .
$ git status
# On branch moons
# Changes to be committed:
Expand Down

0 comments on commit 6736926

Please sign in to comment.