Changes

Jump to: navigation, search

DPS909 & OSD600 Winter 2017 - Lab 4

5,025 bytes added, 12:38, 2 February 2017
Created page with "=Git Branches= In this lab you will review working with branches, and learn how to use the special <code>gh-pages</code> branch on Github to host static web content. ==1. Re..."
=Git Branches=

In this lab you will review working with branches, and learn how to use the special <code>gh-pages</code> branch on Github to host static web content.

==1. Review: creating branches==

Every git repo begins with a single branch named <code>master</code>. When you commit, the <code>master</code> branch is automatically updated to point to the most recent commit.

Recall from class that we can create a new branch by doing the following:

<code>git checkout -b new-branch</code>

The <code>-b</code> flag indicates that you want to first create the branch if it does not already exist, then switch to it and check it out to your working directory. You could also have written it like this:

<code>git checkout -b new-branch master</code>

In this case, we are explicitly specifying that we want <code>new-branch</code> to be created and point to the same commit to which <code>master</code> is pointing. Because we're already on the <code>master</code> branch, we don't have to do this--git will assume you want to use the current commit. We could also have written it like this:

<code>git checkout -b new-branch HEAD</code>

Here we explicitly specify that we want to use the latest commit on the current branch, also known as <code>HEAD</code>.

If we wanted to have <code>new-branch</code> get created pointing to something other than the latest commit, we can specify that commit instead. For example, if we want it to point back to two commits from the current one (i.e., go back in time), we'd do this:

<code>git checkout -b new-branch HEAD~2</code>

As you switch between branches, if you ever get confused about which branch you're on, use <code>git status</code> or <code>git branch</code>, both of which will indicate the current branch.

==2. Resetting a Branch==

Sometimes it's necessary to switch the commit to which a branch is pointing. For example, if you accidentally commit things on <code>master</code> vs. a new branch, and need to move <code>master</code> back to a commit in the same history as a remote repository (i.e., if you want to <code>git pull upstream master</code> to get new updates).

Let's walk through an example:

# On Github, fork the Spoon-Knife repository at https://github.com/octocat/Spoon-Knife
# Clone this repository to your local computer
# Confirm that you are on the <code>master</code> branch (i.e., use <code>git branch</code>)
# Create a '''new file''' called <code>name.txt</code> with your first name in it
# Use git to <code>add</code> and <code>commit</code> the new <code>name.txt</code> file.
# Confirm that you have 1 new commit on the <code>master</code> branch (i.e., use <code>git log</code>)

At this point we have a new commit on the master branch, but decide that we should have done this work on a new branch. Let's fix things so master is back where it should be, and we instead have a new branch:

# Create a new branch called <code>name</code> by doing <code>git checkout -b name</code>
# Confirm that you are now on the <code>name</code> branch
# Confirm that <code>name</code> and <code>master</code> both point to the same commit (i.e., use <code>git show name</code> and <code>git show master</code>)

We can now move our <code>master</code> branch back one commit, and leave our <code>name</code> branch where it is. We'll do that using the <code>-B</code> flag (note the capital), which will '''create or reset''' a branch:

# <code>git checkout -B master HEAD~1</code>
# Confirm that <code>name</code> and <code>master</code> both point to '''different''' commits (i.e., use <code>git show name</code> and <code>git show master</code>)

==3. Merging==











After you've picked your bug, add your '''name''' and the '''issue number''' to the table below

{| class="wikitable"
! style="font-weight: bold;" | #
! style="font-weight: bold;" | Name
! style="font-weight: bold;" | Spoon-Knife Repo (URL)
! style="font-weight: bold;" | Hosted gh-pages Site (URL)
|-
| 1
|
|
|
|-
| 2
|
|
|
|-
| 3
|
|
|
|-
| 4
|
|
|
|-
| 5
|
|
|
|-
| 6
|
|
|
|-
| 7
|
|
|
|-
| 8
|
|
|
|-
| 9
|
|
|
|-
| 10
|
|
|
|-
| 11
|
|
|
|-
| 12
|
|
|
|-
| 13
|
|
|
|-
| 14
|
|
|
|-
| 15
|
|
|
|-
| 16
|
|
|
|-
| 17
|
|
|
|-
| 18
|
|
|
|-
| 19
|
|
|
|-
| 20
|
|
|
|-
| 21
|
|
|
|-
| 22
|
|
|
|-
| 23
|
|
|
|-
| 24
|
|
|
|-
| 25
|
|
|
|-
| 26
|
|
|
|-
| 27
|
|
|
|-
| 28
|
|
|
|-
| 29
|
|
|
|-
| 30
|
|
|
|-
| 31
|
|
|
|-
| 32
|
|
|
|-
| 33
|
|
|
|-
| 34
|
|
|
|-
| 35
|
|
|
|}

==Submission==

You will have completed your lab when you have done the following:

* Setup Bramble and Thimble on your local computer, and taken a '''screenshot''' of it running in your browser
* Picked a '''bug''' to fix in Thimble
* Written a blog post discussing what it was like setting up Thimble, what you learned, and which bug you chose. What is the bug about?
* Added a row to the table above with your '''name''', '''issue URL''', and '''blog post URL'''.

Navigation menu