You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-25
Original file line number
Diff line number
Diff line change
@@ -55,10 +55,10 @@ A version control system.
55
55
A remote location where you can store you code, and which all the members of the team have access to. Think of it like a dropbox for code. One of the big differences however is most repositories on github are public. Anybody can see your code.
56
56
57
57
##### *Commit*
58
-
A way of saving your code at different points along the project. Unlike many tools you may have used however, all commits are saved. This creates a project history and a way to track changes.
58
+
A way of saving your code at different points along the project. Unlike many tools you may have used however, all commits are saved. This creates a project history and a way to track changes.
59
59
60
60
##### *Branches*
61
-
As you work on a git repo the first branch you are on is usually the default branch. This is often called `master`. If you start working on a section of the website (say the footer styling), it is best practise to create your own branch for that feature. Creating your own branch is like taking a copy of `master` and renaming it. When you commit, they will now be on that new branch only.
61
+
As you work on a git repo the first branch you are on is usually the default branch. This is often called `master`. If you start working on a section of the website (say the footer styling), it is best practise to create your own branch for that feature. Creating your own branch is like taking a copy of `master` and renaming it. When you commit, they will now be on that new branch only.
62
62
63
63
In the sections below we will walk through how to do this. For the meantime, just note that you always have one default branch, and can have as many other branches as needed.
64
64
@@ -78,7 +78,7 @@ Git can provide you with a complete history of every commit made on a project. B
78
78
In the introduction section of this tutorial, we won't be able to cover all these benefits in practise extensively. However, we will aim to give you all the information you will need to know by the end.
79
79
80
80
##### Multiple people working on the same files
81
-
Version control makes this possible. If you work on one file, and then I work on the same file at the same time when we want to combine our changes git allows us to keep both versions save that we can compare. This allows us to integrate our changes more swiftly.
81
+
Version control makes this possible. If you work on one file, and then I work on the same file at the same time when we want to combine our changes git allows us to keep both versions save that we can compare. This allows us to integrate our changes more swiftly.
82
82
83
83
We will practice with this later.
84
84
@@ -104,7 +104,7 @@ Windows use http://git-scm.com/download/win. and Linux install using these instr
104
104
105
105
<aname="getting-started"id="getting-started"></a>
106
106
### Getting Started
107
-
The next step is to clone the forked version of this repository. On the main page of the repo, copy the url shown here:
107
+
The next step is to clone the forked version of this repository. On the main page of the repo, copy the url shown here:
108
108
109
109

You should now be ablle to redirect into the directory just created using the command line.
118
118
119
-
Next, it is good to get in the habit after each command to use `git status`. Let us use it now.
119
+
Next, it is good to get in the habit after each command to use `git status`. Let us use it now.
120
120
121
121
```
122
122
git status
@@ -157,12 +157,12 @@ git branch
157
157
Now you can see you are on that branch. Go back to master and now we are going to delete `new-branch`.
158
158
159
159
```
160
-
git checkout master
160
+
git checkout master
161
161
git branch -d new-branch
162
162
git branch
163
163
```
164
164
165
-
As you can see, your branch is now gone.
165
+
As you can see, your branch is now gone.
166
166
167
167
168
168
<a name="changes" id="changes"></a>
@@ -193,7 +193,7 @@ git status
193
193
```
194
194
195
195
Now you can see the file name has turned green. Now to commit your changes.
196
-
196
+
197
197
```
198
198
git commit -m 'adding new command in the cheatsheet'
199
199
git status
@@ -218,7 +218,7 @@ git merge master
218
218
```
219
219
220
220
Even though in this situation there isn't any changes to merge, it is best to get in the habit on going through these steps in your work flow. Merging like this means taking any possible changes in master and merging them with the branch you are currently on.
221
-
After you merge with master you have to push your changes to the remote repo (Github).
221
+
After you merge with master you have to push your changes to the remote repo (Github).
222
222
223
223
```
224
224
git push origin update-cheatsheet
@@ -238,7 +238,7 @@ And then make a pull request to master
238
238
239
239
Afterwards you will see a merge button. Press it and delete your branch. Now your remote branch master is completely up to date with your latest changes.
240
240
241
-
Return to your terminal and navigate to your local master branch. Pull down. You will see your branch update (fast-forward). Delete the branch `update-cheatsheet`.
241
+
Return to your terminal and navigate to your local master branch. Pull down. You will see your branch update (fast-forward). Delete the branch `update-cheatsheet`.
242
242
243
243
244
244
<a name="conflicts" id="conflicts"></a>
@@ -271,9 +271,9 @@ Merge with master. You should have a git conflict that looks something like this
Do you see the lines at the top. The first section is labelled `HEAD` those are from this branch. The next section is from master. Delete the lines, and any other code you want until the cheatsheet looks like how you want it to look.
274
+
Do you see the lines at the top. The first section is labelled `HEAD` those are from this branch. The next section is from master. Delete the lines, and any other code you want until the cheatsheet looks like how you want it to look.
275
275
276
-
Afterwards git status, add the files in red, commit, and push. Then make a pull request to master like before and merge. Don't forget to update your local master branch, and delete the merged branch in Github and in your local repo. It is good to keep your working environments clean and organised.
276
+
Afterwards git status, add the files in red, commit, and push. Then make a pull request to master like before and merge. Don't forget to update your local master branch, and delete the merged branch in Github and in your local repo. It is good to keep your working environments clean and organised.
277
277
278
278
279
279
<a name="github-flow" id="github-flow"></a>
@@ -311,7 +311,7 @@ As discussed previously git stores all the commits on the project. You can use t
311
311
312
312
Before we start make sure you have a terminal open located at the local copy of this repo. The same one that was used for the first tutorial is essential. Make a new branch called `timeline-practice` and navigate onto it.
313
313
314
-
Make a new directory in the project via the command line. Lets call it `time`.
314
+
Make a new directory in the project via the command line. Lets call it `time`.
315
315
316
316
```
317
317
mkdir time
@@ -355,8 +355,8 @@ Next, we should go back to the future. The quickest and easiest way is to checko
355
355
356
356

357
357
358
-
Find the commit name of the last commit you did (the third time that you recorded) and copy the short hash in yellow. Checkout back to that commit, and `git diff timeline-practise` there should be no difference.
359
-
Checkout back to `timeline-practise` and push up to Github to make a pull request to master. Make sure you first check that
358
+
Find the commit name of the last commit you did (the third time that you recorded) and copy the short hash in yellow. Checkout back to that commit, and `git diff timeline-practise` there should be no difference.
359
+
Checkout back to `timeline-practise` and push up to Github to make a pull request to master. Make sure you first check that
360
360
it is up to date with master locally.
361
361
362
362
@@ -369,23 +369,23 @@ it is up to date with master locally.
369
369
370
370
You should aim each commit to be a "safe" version of the project. This means that if you checkout to any commit in your timeline, that should reflect where the project was at that point, and be functional.
371
371
372
-
Given that, when you commit is very important. I have heard two very useful guidelines.
372
+
Given that, when you commit is very important. I have heard two very useful guidelines.
373
373
374
374
The first, is that a you complete the task assigned to you, you make several commits at different times during that task. In the end you merge all those commits together to make one very informative commit of that task. I will talk about ways to merge commits together in a later section.
375
375
376
-
The second method is you work through your task and complete it before adding or committing at all. Then you check the status of the repo and see all the files you have changed. The next step is selectively adding and committing
376
+
The second method is you work through your task and complete it before adding or committing at all. Then you check the status of the repo and see all the files you have changed. The next step is selectively adding and committing
377
377
378
-
Through my research I have come across many different methodologies, and ultimately you should try to do what seems the most natural to you. I use both of these methodologies depending on the extend of the task before me. The best thing is to always keep in mind that you and your colleagues will inevitably need to go back to your commits and it will help everyone if commits are aptly named.
378
+
Through my research I have come across many different methodologies, and ultimately you should try to do what seems the most natural to you. I use both of these methodologies depending on the extend of the task before me. The best thing is to always keep in mind that you and your colleagues will inevitably need to go back to your commits and it will help everyone if commits are aptly named.
379
379
380
380
Likewise, even in pull requests, you must aim to make your commits a clear and concise summary of what tasks where completed on that branch. That way the person reviewing your pull request understands what they will be reviewing before looking at the code itself.
381
381
382
382
383
383
<a name="commit-message" id="commit-message"></a>
384
384
### Commit messages
385
385
386
-
Just like choosing when to commit, and what to commit, it is also important to think about your naming. It is always good to be as descriptive as possible with your commit messages.
386
+
Just like choosing when to commit, and what to commit, it is also important to think about your naming. It is always good to be as descriptive as possible with your commit messages.
387
387
388
-
Also consider:
388
+
Also consider:
389
389
* Present tense for your commit messages
390
390
* If related to an issue on github, should contain issue number
391
391
* The first line should be 50 characters or less. Your message should be brief and to the point.
@@ -409,7 +409,7 @@ Often you will find yourself wanting to merge commits, or organising your early
409
409
#### Reset Soft
410
410
This is my preferred method of merging commits together. It leaves you with lots of flexibility.
411
411
412
-
To begin, make a new branch and make some new files and commit regularly (at least twice).
412
+
To begin, make a new branch and make some new files and commit regularly (at least twice).
413
413
414
414
Next `git log` and pick the 3rd most recent hash. Copy it and:
415
415
@@ -431,9 +431,20 @@ For more information and techiques see:
+ Build Podcast (intro to Git) Video: http://build-podcast.com/git/
444
+
+ Git User Manual: https://www.kernel.org/pub/software/scm/git/docs/user-manual.html
445
+
+ GitHub's Treasure Trove of Video Tutorials: https://www.youtube.com/user/GitHubGuides (channel) and *specifically*: https://www.youtube.com/watch?v=FyfwLX4HAxM
446
+
+ The *simple* guide to git: http://rogerdudler.github.io/git-guide/
447
+
+ Jeff Schomay's Git-Fu presentation: http://slides.com/jschomay/git-fu
448
+
+ Git Pretty: http://justinhileman.info/article/git-pretty/ (anything visual makes learning git much easier...)
0 commit comments