-
Install SourceTree or the Git command-line tools, if not already installed. Then clone the repository you created in [Exercise 2].
In SourceTree, You should clone the repository either by going to the repository window Remote tab, or by copying the repository URL in GitHub and using the + New Repository button. From the command line, use
git clone url-from-github
. -
Edit the README file, adding this new content, …
Any text editor will do.
-
Move the README file to the staging area and commit the changes. Verify that the log shows a new commit.
At this point the master branch will be ahead of the origin/master branch. In SourceTree you should be able to see this in the commit list. From the command line, if master is ahead of origin/master, you can tell from the output of
git status
:$ git status On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working directory clean
-
Push the new changes to the remote on GitHub. Verify that the local master branch and the origin/master branch are in synch.
In SourceTree, you should see master, origin/master, and origin/HEAD on the same commit line. From the command line,
git status
should say thatYour branch is up-to-date with 'origin/master'.
-
Create a new file called
hello.md
with this content: … -
Add the new file
hello.md
to the staging area. -
Modify
hello.md
again, adding this new section: … -
Notice that there is now a copy in the staging area, with the original content, and also a copy that is not staged, with the newer content. Add the newer copy to the staging area.
In SourceTree you can see the file listed in both Staged files and Unstaged files. Clicking the checkbox in either will either stage or unstage both. From the command line,
git status
will also show the file twice.On branch master Your branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits) Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: hello.md Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: hello.md
-
Commit the changes.
-
Edit the README file and modify the text as follows: …
-
Stage the changes to the README and commit.
-
Push both commits to the GitHub origin. Verify that both the local master and origin/master are on the same commit.
In SourceTree, you should see master, origin/master, and origin/HEAD on the same commit line. From the command line,
git status
should say thatYour branch is up-to-date with 'origin/master'.