Skip to content

Latest commit

 

History

History
64 lines (48 loc) · 2.84 KB

ex3-solution.asciidoc

File metadata and controls

64 lines (48 loc) · 2.84 KB

Exercise 3 Solution

  1. 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.

  2. Edit the README file, adding this new content, …​

    Any text editor will do.

  3. 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
  4. 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 that Your branch is up-to-date with 'origin/master'.

  5. Create a new file called hello.md with this content: …​

  6. Add the new file hello.md to the staging area.

  7. Modify hello.md again, adding this new section: …​

  8. 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
  9. Commit the changes.

  10. Edit the README file and modify the text as follows: …​

  11. Stage the changes to the README and commit.

  12. 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 that Your branch is up-to-date with 'origin/master'.