Skip to content

Commit

Permalink
Add edited files
Browse files Browse the repository at this point in the history
  • Loading branch information
callaghanmt committed Jan 3, 2018
1 parent a2e0215 commit c1a98d3
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 39 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
carpentry: "swc"

# Overall title for pages.
title: "Version Control with Git"
title: "SWD2: Version Control with Git and Github"

# Contact email address.
email: [email protected]
email: [email protected]

#------------------------------------------------------------
# Generic settings (should not need to change).
Expand Down
6 changes: 3 additions & 3 deletions _episodes/01-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ think of it as a tape: if you rewind the tape and start at the base
document, then you can play back each change and end up with your
latest version.

![Changes Are Saved Sequentially](../fig/play-changes.svg)
![Changes Are Saved Sequentially](../fig/play-changes.png)

Once you think of changes as separate from the document itself, you
can then think about "playing back" different sets of changes onto the
base document and getting different versions of the document. For
example, two users can make independent sets of changes based on the
same document.

![Different Versions Can be Saved](../fig/versions.svg)
![Different Versions Can be Saved](../fig/versions.png)

Unless there are conflicts, you can even play two sets of changes onto the same base document.

![Multiple Versions Can be Merged](../fig/merge.svg)
![Multiple Versions Can be Merged](../fig/merge.png)

A version control system is a tool that keeps track of these changes for us and
helps us version and merge our files. It allows you to
Expand Down
4 changes: 2 additions & 2 deletions _episodes/04-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ but not yet committed.
> than you would like.
{: .callout}

![The Git Staging Area](../fig/git-staging-area.svg)
![The Git Staging Area](../fig/git-staging-area.png)

Let's watch as our changes to a file move from our editor
to the staging area
Expand Down Expand Up @@ -607,7 +607,7 @@ we first need to add the changed files to the staging area
(`git add`) and then commit the staged changes to the
repository (`git commit`):
![The Git Commit Workflow](../fig/git-committing.svg)
![The Git Commit Workflow](../fig/git-committing.png)
> ## Choosing a Commit Message
>
Expand Down
45 changes: 23 additions & 22 deletions _episodes/05-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ $ cat project.txt
{: .bash}

~~~
We could use Github, Gitlab or Bitbucket to host our code.
Notes on what scripts we need to write.
~~~
{: .output}

Expand All @@ -219,6 +219,7 @@ Changes not staged for commit:
modified: project.txt
no changes added to commit (use "git add" and/or "git commit -a")
~~~
{: .output}

We can put things back the way they were
Expand Down Expand Up @@ -246,7 +247,7 @@ As you might guess from its name,
In this case,
we're telling Git that we want to recover the version of the file recorded in `HEAD`,
which is the last saved commit.
If we want to go back even further,
If we want to go back even further, say to the first commit,
we can use a commit identifier instead:

~~~
Expand All @@ -260,7 +261,7 @@ $ cat project.txt
{: .bash}

~~~
Cold and dry, but everything is my favorite color
Some initial data analysis to identify how inflammation changes over time after surgery.
~~~
{: .output}

Expand Down Expand Up @@ -315,12 +316,12 @@ the commit in which we made the change we're trying to get rid of.
In the example below, we want to retrieve the state from before the most
recent commit (`HEAD~1`), which is commit `f22b25e`:
![Git Checkout](../fig/git-checkout.svg)
![Git Checkout](../fig/git-checkout.png)
So, to put it all together,
here's how Git works in cartoon form:
![https://figshare.com/articles/How_Git_works_a_cartoon/1328266](../fig/git_staging.svg)
![https://figshare.com/articles/How_Git_works_a_cartoon/1328266](../fig/git_staging.png)
> ## Simplifying the Common Case
>
Expand Down Expand Up @@ -411,81 +412,81 @@ moving backward and forward in time becomes much easier.
> 1.
>
> ~~~
> Venus is too hot to be suitable as a base
> We need to think about the statistical techniques to apply
> ~~~
> {: .output}
>
> 2.
>
> ~~~
> Venus is beautiful and full of love
> So that we have defensible conclusions
> ~~~
> {: .output}
>
> 3.
>
> ~~~
> Venus is beautiful and full of love
> Venus is too hot to be suitable as a base
> We need to think about the statistical techniques to apply
> So that we have defensible conclusions
> ~~~
> {: .output}
>
> 4.
>
> ~~~
> Error because you have changed venus.txt without committing the changes
> Error because you have changed analysis.txt without committing the changes
> ~~~
> {: .output}
>
> > ## Solution
> >
> > Line by line:
> > ~~~
> > $ cd planets
> > $ cd inflammation
> > ~~~
> > {: .bash}
> > Enters into the 'planets' directory
> > Enters into the 'inflammation' directory
> >
> > ~~~
> > $ nano venus.txt #input the following text: Venus is beautiful and full of love
> > $ nano analysis.txt #input the following text: We need to think about the statistical techniques to apply
> > ~~~
> > {: .bash}
> > We created a new file and wrote a sentence in it, but the file is not tracked by git.
> >
> > ~~~
> > $ git add venus.txt
> > $ git add analysis.txt
> > ~~~
> > {: .bash}
> > Now the file is staged. The changes that have been made to the file until now will be committed in the next commit.
> >
> > ~~~
> > $ nano venus.txt #add the following text: Venus is too hot to be suitable as a base
> > $ nano analysis.txt #add the following text: So that we have defensible conclusions
> > ~~~
> > {: .bash}
> > The file has been modified. The new changes are not staged because we have not added the file.
> >
> > ~~~
> > $ git commit -m "Comment on Venus as an unsuitable base"
> > $ git commit -m "Thoughts on statistical techniques"
> > ~~~
> > {: .bash}
> > The changes that were staged (Venus is beautiful and full of love) have been committed. The changes that were not staged (Venus is too hot to be suitable as a base) have not. Our local working copy is different than the copy in our local repository.
> > The changes that were staged (We need to think about the statistical techniques to apply) have been committed. The changes that were not staged (So that we have defensible conclusions) have not. Our local working copy is different than the copy in our local repository.
> >
> > ~~~
> > $ git checkout HEAD venus.txt
> > $ git checkout HEAD analysis.txt
> > ~~~
> > {: .bash}
> > With checkout we discard the changes in the working directory so that our local copy is exactly the same as our HEAD, the most recent commit.
> >
> > ~~~
> > $ cat venus.txt #this will print the contents of venus.txt to the screen
> > $ cat analysis.txt #this will print the contents of analysis.txt to the screen
> > ~~~
> > {: .bash}
> > If we print venus.txt we will get answer 2.
> > If we print analysis.txt we will get answer 1.
> >
> {: .solution}
{: .challenge}
> ## Checking Understanding of `git diff`
> ## Checking Understanding of git diff
>
> Consider this command: `git diff HEAD~3 project.txt`. What do you predict this command
> will do if you execute it? What happens when you do execute it? Why?
Expand All @@ -508,7 +509,7 @@ moving backward and forward in time becomes much easier.
> Exploring history is an important part of git, often it is a challenge to find
> the right commit ID, especially if the commit is from several months ago.
>
> Imagine the `planets` project has more than 50 files.
> Imagine the `inflammation` project has more than 50 files.
> You would like to find a commit with specific text in `project.txt` is modified.
> When you type `git log`, a very long list appeared,
> How can you narrow down the search?
Expand Down
2 changes: 1 addition & 1 deletion _episodes/07-github.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ To https://github.com/ARCTraining/inflammation.git
Our local and remote repositories are now in this state:
![GitHub Repository After First Push](../fig/github-repo-after-first-push.svg)
![GitHub Repository After First Push](../fig/github-repo-after-first-push.png)
> ## The '-u' Flag
>
Expand Down
2 changes: 1 addition & 1 deletion _episodes/08-collab.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $ git clone https://github.com/jane/inflammation.git ~/Desktop/jane-inflammation

Replace `jane` with the correct username for your collaborator.

![After Creating Clone of Repository](../fig/github-collaboration.svg)
![After Creating Clone of Repository](../fig/github-collaboration.png)

The Collaborator can now make a change in her clone of the Owner's repository,
exactly the same way as we've been doing before:
Expand Down
13 changes: 9 additions & 4 deletions _episodes/09-conflict.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,15 @@ $ cat project.txt
{: .bash}

~~~
Cold and dry, but everything is my favorite color
The two moons may be a problem for Wolfman
But the Mummy will appreciate the lack of humidity
We removed the conflict on this line
Some initial data analysis to identify how inflammation changes over time after surgery.
Jane is a Data Scientist and Samit is a statistician. We'll need to determine
who is responsible for what in this project.
We may need to bring a third person with Python programming skills into the project.
The third team member needs to be competent in both Python and R. They
also need to be familiar with matplotlib and ggplot
Add a different line to the originator's copy
This line added to the collaborator's copy
~~~
{: .output}

Expand Down
Binary file modified fig/github-collaboration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 0 additions & 4 deletions setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ title: Setup
permalink: /setup/
---

Please see [this section of the workshop template][workshop-setup]
for instructions on installing Git.

We'll do our work in the `Desktop` folder so make sure you change your working directory to it with:

~~~
Expand All @@ -15,4 +12,3 @@ $ cd Desktop
~~~
{: .bash}

[workshop-setup]: https://swcarpentry.github.io/workshop-template/#git

0 comments on commit c1a98d3

Please sign in to comment.