Skip to content

Commit b1b0559

Browse files
committed
Update first part of c1s2 to use sourcetree
1 parent 899f4a4 commit b1b0559

File tree

5 files changed

+2554
-2361
lines changed

5 files changed

+2554
-2361
lines changed

_sessions/c1s2/1_using_git.md

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,90 @@
22
title: "Intro to Git"
33
---
44

5+
Git is a version control system. It allows you to keep the entire history of your code, and makes it easy to share and collaborate with others.
6+
7+
To use git you need to create a **Git repository**. You can think of a git repository like this:
8+
59
![Basic git](/assets/basic_git.png)
610

7-
Git is a version control system. It allows you to keep the entire history of your code, and makes it easy to share and collaborate with others.
11+
- A repository contains lots of **commits**. Each commit is essentially a different version of your files.
12+
- Commits can be organised into **branches**. A repository can contain many different branches. Branches are often used to develop new application features - that way the main codebase still works while the feature is being developed, and the new code can be *merged* in when it's working.
13+
- Branches have names, so you can keep track of them. When you first set up a repository, you'll just have one branch and it will have the default name - **master**.
814

9-
### Setting up a git repo
15+
### What does a git repository look like?
1016

11-
Git works on a folder level. To set up a folder to work with git you need to open up the github app and select `File > Add Local Repository ...`. You then need to select the folder you want to control with git.
17+
On your laptop, a git repository is just a **special type of folder**. Any folder can be made into a git repository (but not all folders should - e.g. don't make your entire documents directory into a git repository, you'll run into problems). You'll normally make a new git repository for each coding project you work on.
1218

13-
### Excluding some files
19+
If you look inside the folder, you won't see all the different versions stored there (they are actually there - just stored inside a hidden folder called `.git`) - you'll only see the files that are in your **working copy**. Normally this working copy will contain the files from the last commit on the master branch, along with any changes you've made.
1420

15-
There are some other hidden files (e.g. those used by your operating system) that you don't want to be version controlled. An example of these is the `.DS_Store` file on macs. We'll talk more about this later - for now we'll just quickly exclude them from our repository.
21+
### Making a commit
1622

17-
To do this you need to change the settings on your repository.
23+
To save some changes into the repository you need to create a commit. When you create a commit you get to write a message, to help remind yourself (and others) what changes you made (and why you made them). Once you've created a commit, you'll be able to come back to this version of your code at any point in the future.
1824

19-
1. Open the settings tab of your repository.
20-
2. Add `.DS_Store` on the first line of the 'Ignored files' section, and press 'Save Changes'.
25+
Adding files to a git repository is actually a two-stage process: first you have to **add** them to something called the **index** and then you have to **commit** them. This is useful when you get more advanced, but we'll usually do those things together for the time being.
2126

22-
If you're on Windows you don't need to worry about this.
27+
![Index and working tree](/assets/index_working_tree.png)
2328

24-
### Committing files to the repository
29+
{% exercise %}
30+
1. Set up your `first_site` folder as a git repository.
31+
2. **Add** your work to the index.
32+
3. **Commit** your work to the repository, with a message e.g. "Initial import"
33+
4. Make some change to index.html (in Sublime Text)
34+
5. **Add** your changes to the index.
35+
6. **Commit** them to the repository.
36+
{% endexercise %}
2537

26-
Suppose we've now created a file called `index.html` in the folder. It's in the folder but currently isn't being tracked by git.
2738

28-
Adding files to a git repository is actually a two-stage process: you have to **add** them and then **commit** them. This is useful when you get more advanced, but we'll usually do those things together for the time being.
39+
### Git with SourceTree
2940

41+
#### Creating a git repository
3042

31-
{% exercise %}
32-
1. Set up your `first_site` folder as a git repository: open up the github app, select `File > Add Local Repository ...` and select the `first_site` folder.
33-
2. **If you are on a mac**, tell git to ignore your `.DS_Store` files: in the settings panel of the github app, add the line `.DS_Store` in the 'Ignored files' section.
34-
3. Commit your work to the repository: in the 'Changes' panel, click 'Select all', write a 'Commit Summary' in the box (e.g. "Created index.html") and click 'Commit'.
35-
6. Make some change to index.html (in Sublime Text)
36-
7. Go back to the 'Changes' panel. Select and commit your changes, with a 'Commit Summary' describing what you did.
37-
{% endexercise %}
43+
1. Open SourceTree
44+
2. Select File > New / Clone
45+
3. Select the 'New' option
46+
4. Navigate to the folder you want to make into a git repository.
47+
48+
#### Adding to the index
49+
50+
1. Select all the files in the working tree section.
51+
2. Click the "Add" button at the top.
52+
3. You should see the files move to the 'Index' section
53+
54+
#### Committing to the repository
55+
56+
1. Once you have files in your 'Index' section, click on 'Commit'.
57+
2. Write a commit message explain what you've done (and maybe why).
58+
3. Click "Commit"
59+
60+
### Git with the command line
61+
62+
#### Creating a git repository
63+
64+
1. Using the command line, navigate to the folder you want to make into a repository.
65+
2. **Inside the target folder** run the command
66+
67+
git init
68+
69+
3. To check this worked run the command
70+
71+
git status
72+
73+
#### Adding to the index
74+
75+
1. Inside the folder, run the command
76+
77+
git add --all
78+
79+
3. To check this worked run the command
80+
81+
git status
82+
83+
#### Committing to the repository
84+
85+
1. Inside the folder, run the command
86+
87+
git commit -m "write your message here"
88+
89+
3. To check this worked run the command
90+
91+
git status

_sessions/c1s2/2_pushing_to_github.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
title: Pushing code to Github
33
---
44

5-
65
Github is a site which will host a git repo online for you, making it easy to collaborate with others. We'll now see how to put some code online.
76

87
### Aside: serving a site via Github Pages
@@ -24,4 +23,9 @@ To push code up to GitHub, in the GitHub app select the 'Push to Github' button
2423
3. On Github check you can see your `first_site` code.
2524
4. On the code page on github, click on Settings. It should tell you (about half way down) the url where they've published your site. Have a look to see whether you can see it!
2625
5. (If you finish early) Make a change to `index.html` in Sublime Text. Commit the change to the repository and then push it to GitHub. Make sure you can see the change in the code on GitHub and also in the published page.
27-
{% endexercise %}
26+
{% endexercise %}
27+
28+
### Creating a git repository, adding and committing with Source Tree
29+
30+
#### To
31+

0 commit comments

Comments
 (0)