Skip to content

Commit

Permalink
Updating Github notes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiekazil authored and elliethebrave committed Sep 11, 2014
1 parent aac8e16 commit 5ff5751
Show file tree
Hide file tree
Showing 2 changed files with 143 additions and 5 deletions.
4 changes: 3 additions & 1 deletion notes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ Additionally, we have more detailed tutorials for things we covered briefly:
- [How to ask questions when you need help](https://github.com/ireapps/scraping-class/blob/master/notes/how-to-ask-questions.md)

Finally, here's some extra info:
- [Helpful links](https://github.com/ireapps/scraping-class/blob/master/notes/helpful-links.md)
- [Helpful links](https://github.com/ireapps/scraping-class/blob/master/notes/helpful-links.md)

*Note: Let us know if we can improve these notes.*
144 changes: 140 additions & 4 deletions notes/github-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,22 @@ Let's sign up for Github and create our own repos!
<img src="https://cloud.githubusercontent.com/assets/166734/4175599/b38ed07c-35dc-11e4-98a3-3140d33ae426.png" alt="Github profile page"/>
</p>

## Set your username and email up on your machine

When we interact with Git from the command line, this will make those interactions easier.

Enter the following commands into Terminal. Remember to replace the name and email with the user name and email that you set up your account with.

*Terminal*
```
git config --global user.name "elliethebrave"
git config --global user.email "[email protected]"
```
If you error, you can override the error by resubmitting the same command with the correct information.

## Let's set up our first repository

In the top right of the page, select create ```New Repository``` from the ```+ ``` menu next to your name on the top right.
In the top right of the github page, select create ```New Repository``` from the ```+ ``` menu next to your name on the top right.

<p align="center">
<img src="https://cloud.githubusercontent.com/assets/166734/4176397/dfb79b96-3601-11e4-9267-ed543aac62b0.png" alt="Github create repository menu"/>
Expand All @@ -130,9 +142,133 @@ Things to consider on this form:

Submit the filled out form.

#### Set your username and email up on your machine
Afterwards, Github will redirect you to the page of the repository.

## Interacting with Github from the commandline

You will do most of your work from the commandline. Let's copy our new repo to our machine via the commandline.

### Cloning the repository

At the bottom of the menu on the right, you will see a box with the URL that looks like this;

![screen shot 2014-09-10 at 10 48 31 pm](https://cloud.githubusercontent.com/assets/166734/4228580/2295c1a4-395e-11e4-84b1-100172a1ddd4.png)

That is the URL that we are going to clone to our machine locally.

Open up your Terminal window and cd into the directory where you like to put code. Below is the one that we used in the example, but you will want to make sure to use your own.

*Terminal*
```
git config --global user.name "elliethebrave"
git config --global user.email "[email protected]"
git clone https://github.com/elliethebrave/chihuahuas.git
```

Afterwards, if you ```ls```, you will see a new directory with the name of your repository. You will want to ```cd``` into that directory.

```
cd chihuahuas
```

### Making a change and updating on Github

In this directory, you will find the same content that you see on the website. Let's update the content and push to github. Open the read me from your desktop and edit it or add more information, then save it.

Afterwards, got back to Terminal and from inside the project folder, run the following:

```
git diff
```

You should see the change that you made. In my case, it looks like this:

```
diff --git a/README.md b/README.md
index fc5a574..f56ef88 100644
--- a/README.md
+++ b/README.md
@@ -2,3 +2,5 @@ chihuahuas
==========
Chihuahuas! What's not to love?!?!
+
+This is going to be an app that allows people to share how much they love Chihauhaus with each other!
```

If you run

Now, we will want to 'commit' this change to the repository. To do so, run the following with a message between the quotes that describes the commit that you are making.

```
git commit -am "This commit updates the language used to describe the project."
```

(Note: The '-am' means, add an '-a' flag, and a '-m' flag. An '-a' flag means add all changes. While a '-m' means that there is a commit message that is to be expected.)

Running this, should return something that looks like this:
```
[master e7a42ac] This commit updates the language used to describe the project.
1 file changed, 2 insertions(+)
```

At this point, you have committed the change locally, but you need to tell Github that the change has been made by pushing it remotely. Enter the following into Terminal from the project folder:

```
git push origin
```

At this point, you will be prompted to enter your password. When it is successful, you should see something like this:

```
...
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 432 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/elliethebrave/chihuahuas.git
e78e20f..e7a42ac master -> master
```

At this point, the changes are up on github. If you visit the project on the site you will see the commits that you pushes from the [commits page](https://github.com/elliethebrave/chihuahuas/commits/master).

Let's try the same with adding a file.

### Adding a file and uploading it to Github

Start by adding a file. Let's pretend we are going to start a script.

Add the following line to a new file and save it as 'hello_world.py' in the project directory:
```
print "Hello world."
```

When you run the file, ```python hello_world.py``` it will return to you "Hellow World."

This time, if you run ```git diff``` nothing will happen. Try running a new command ```git status```.

Read what it returns...

```
...
Untracked files:
(use "git add <file>..." to include in what will be committed)
hello_world.py
...
```

So, we need to add the file. Run the following command to add it.
```
git add hello_world.py
```

Now run ```git status``` again. What does it say now? "new file"? If so, good. What else does the message tell you?

After that we want to commit the file locally, then push the addition up to Github, just like we did in the previous exercise.

```
git commit -am "Adding a hello world script."
git push origin
```
Now if you visit your repository you should see the changes you made! YAY! EXCITING!

0 comments on commit 5ff5751

Please sign in to comment.