This document follows set-up from the previous document

## First, Edit the README document

• Add your name and a bullet list with three of your favorite foods to the README.md document.

## Branch

1. Create a branch “version2

• The funny icon (see image, below) is used to create and checkout a branch
• Clicking the icon invokes a new branch function. (Don’t type the next command. Just know invoking the brach via RStudio makes git spawn the following command: git checkout <<branch-name>> )
• For a branch name, in the branch text box, type: version2
• Click Create
1. Back to the RStudio text editor, create a new text file listing three favorite movies. Save the file as movies.md. Commit and push your changes
2. Checkout the master branch

• Watch the Files tab as you switch back to the master branch. Where is the movies.md file?
• See the image below…

1. First, click the existing branch name: version2
2. Then, select master within the “LOCAL BRANCH” context menu
1. Checkout the version2 branch again

2. Observe the visual representations of the branching and updating

• In the RStudio git tab, click the clock (for history)

• Observe the timestamped versions you commited as part of the version2 branch.
• Alternatively, within your repo at GitHub.com: Insights > Network

## Merge

1. Checkout the master branch

• In the Terminal window type: git merge version2
• You should see a terminal response similar to below…
Updating 83fb5bb..08c9267
Fast-forward
movies.md | 5 +++++
2 files changed, 12 insertions(+), 1 deletion(-)
create mode 100644 movies.md
1. Observe the visual representations of the version history

## Conflict

1. Edit README.md in master by changing your name. Commit then Push.
2. Edit README.md in version2 by changing the name to something different from the step above. Commit then Push.
3. Checkout master, then git merge version2
4. Fix Conflicts, then Save. ; Commit and Push.
5. Observe the visual representations of the version history

## Revert

1. Checkout master
2. Create New text file, colors.md and list three of your favorite colors
3. Commit and Push
4. Add a fourth color to colors.md ; Commit and Push
5. Observe the visual representations of the version history
6. Now revert the last change because you changed your mind and you don’t have four favorite colors. In the terminal window type…
git revert HEAD
• This pushes you into a UNIX text editor. The full explanation is tedious. Just type Esc, then :wq then Enter
1. Commit and Push.
2. Observe the visual representations of the version history

#### NOTE

A full explanation of git revert and git reset will take considerably more time. If you find you do this a lot, investigate these commands fully.

#### HINT

For small changes, many people find a far simpler method is as follows…

1. At GitHub, click the “Commits” link
2. Isolate the version you need by clicking the < > link. This enables you to browse the repository at that point in history
3. Navigate to the file you need. Copy the file.

• Or, alternatively, you can download a copy of the whole repository (look for the green “clone” button, then “download zip”) at that commit point
4. Back in your editor, paste over the source version.
Commit & Push

## Roll back

The above example is a trivial example of how to employ rolling back to a previous version. Rolling back is complicated. Depending on the complexity of your project, it may be more critical to leverage git commands during a roll-back. Software applications may be an example of this complexity. However, for simpler roll-backs, the simple explanations below may save you a lot of time for an operation which you would otherwise rarely perform.

### File

Sometimes the easiest thing to do is grab the file (or subtext from a file) in a previous commit that is already displayed on GitHub. To do so.

1. Find your repository on GitHub
2. Click the “commits” tab
3. Click the SHA link for the commit which has the most recent working version
4. Click the filename representing the working file you want
5. Click View; Raw
6. Copy what you want and over-write your local repository with the previously working version