Skip to content

Commit 9b37d98

Browse files
committed
Import legacy 'git'
1 parent f405cd6 commit 9b37d98

27 files changed

+1483
-8
lines changed

legacy/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ TODO, find the info about the stuff that happens _before_ the course, and add it
1616
| Name | Reference | Weeks |
1717
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ----- |
1818
| [HTML & CSS](./html-and-css/) | [ref](https://github.com/HackYourFuture-CPH/HTML-CSS/tree/5217f5807129ec894aa43e04d1f7dd5465966de2) | 1 |
19-
| [Git (part 1)](./git-1/) | [ref](https://github.com/HackYourFuture-CPH/Git/tree/b5499a64a7957e614ed92ab4545d6fd80ddd030c/Git1) | 1 |
19+
| [Git (part 1)](./git/git1/) | [ref](https://github.com/HackYourFuture-CPH/Git/tree/b5499a64a7957e614ed92ab4545d6fd80ddd030c/Git1) | 1 |
2020
| [JavaScript (in 3 parts)](./javascript/) | [ref](https://github.com/HackYourFuture-CPH/JavaScript/tree/675adba05e23ccf1b52d653e03f7d9b1f11c4e09) | 10 |
2121
| [Databases](./databases/) | [ref](https://github.com/HackYourFuture-CPH/databases/tree/171a567db330f704d1f40ce35516cc41a84d1cdf) | 3 |
2222
| [NodeJS](./nodejs/) | [ref](https://github.com/HackYourFuture-CPH/node.js/tree/063085194a02eb1610b614d7be20372b4797001b) | 3 |
2323
| [React (in 2 parts)](./react/) | [ref](https://github.com/HackYourFuture-CPH/React/tree/0bdef59114ba678adf3b10ddedcb74f4f4b04781) | 6 |
24-
| [Git (part 2)](./git-2/) | [ref](https://github.com/HackYourFuture-CPH/Git/tree/b5499a64a7957e614ed92ab4545d6fd80ddd030c/Git2) | 1 |
24+
| [Git (part 2)](./git/git2/) | [ref](https://github.com/HackYourFuture-CPH/Git/tree/b5499a64a7957e614ed92ab4545d6fd80ddd030c/Git2) | 1 |
2525
| [Career training](./career-training/) | [ref](https://github.com/HackYourFuture-CPH/career-training/tree/0050e4be53cfb06cad2cbd764ef41385a5141f51) | 3 |
2626
| [Final project](./final-project/) | [ref](https://github.com/HackYourFuture-CPH/finalproject/tree/5a9b0fee893816e9c994771e3146760f0f70b726) | 4–5 |
2727

legacy/git-1/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

legacy/git-2/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

legacy/git/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Git
2+
3+
This repository contains the course material for the Git modules :octocat:.
4+
5+
Git course was first introduced in the Hack Your Future (HYF henceforth) in September 2016. We think that learning Git is one of the useful skills to become a successful and efficient software engineer. The aim of this course is to learn the basics of Git and not to be an expert. Both Git1 and Git2 are designed to be run as one session each.
6+
7+
We want to use this repository as an archive of course material (slides/tutorials), useful resources, teaching ideas etc.
8+
9+
Also check out our Git [playlist](https://www.youtube.com/playlist?list=PLVYDhqbgYpYUGxRdtQdYVE5Q8h3bt6SIA) for tutorials
10+
11+
| Module | Learning goals | Preparation | Lesson Plan | Homework |
12+
| ------ | -------------------------------------------------------------------- | ------------------------------------ | ------------------------------------ | ------------------------------ |
13+
| 1. | Introduction to Git; Git vs GitHub; Pull Requests; Commits; Branches | [Preparation](./git1/preparation.md) | [Lesson Plan](./git1/lesson_plan.md) | [Homework](./git1/homework.md) |
14+
| 2. | Advanced Git and Preparation for the Final Project | [Preparation](./git2/preparation.md) | [Lesson Plan](./git2/lesson_plan.md) | [Homework](./git2/homework.md) |
15+
16+
Please check the material shared on Preparation, Lesson Plan and Homework ⬆️

legacy/git/git1/GIt_branches.pdf

622 KB
Binary file not shown.

legacy/git/git1/Git_basics.pdf

152 KB
Binary file not shown.

legacy/git/git1/cheatsheet.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Cheat sheet
2+
3+
Here are the commands we used in the class (and a few more) and their meaning.
4+
5+
## Command line
6+
7+
- `pwd` - stands for 'print working directory' and you use it to know in which directory you are.
8+
- `cd <folder_name>` - stands for 'change directory', and you use it to go inside `folder_name`.
9+
- `cd ..` - to go to the parent folder of your current folder.
10+
- `mkdir <folder_name>` - stands for 'make directory' and you use it to create a new folder with `folder name`.
11+
- `ls` - stands for 'list' and you use it list all the folder contents.
12+
- `ls .*` - list all the folder contents, also invisible folders/files (e.g. the .git folder).
13+
- `rm <file_name>` - THIS IS DANGEROUS!!! It removes the file named `file_name` FOREVER, you can NEVER recover it.
14+
15+
To remove a git repository but still keep your files do `rm -rf .git` in the folder where you have the repository. All the git information is lost when you do this.
16+
17+
## Git
18+
19+
### Part 1
20+
21+
We used these commands in the first part of the class to work with a local git repository on our own computers.
22+
23+
- `git add <file_name>` - tells git to start tracking a file or to update what will be commited. Always do that before `git commit`.
24+
- `git commit -m "commit_message"` - commit your changes.
25+
- `git push origin <branch_name>` - push (upload) your changes in your current branch to your github repository into the branch named `<branch_name>`.
26+
- `git status` - shows you which files are ready to be commited, or not tracked by git. Often tells you what to do as well. It is your best friend when using git :)
27+
- `git log` - shows the history of commits in the current branch.
28+
- `git log --oneline` - shows the history of commits in the current branch in a single line per commit.
29+
- `git diff <file_name>` - to see the difference between the file contents now and in the latest commit.
30+
31+
Note: if you do `git add .` instead of `git add <file_name>` you will add all files in your current folder.
32+
33+
### Part 2
34+
35+
We used these commands in the second part of the class to create a branch, go to it, commit our changes on that branch, and then push it to Github.
36+
37+
- `git branch <branch_name>` - create a new branch `<branch_name>`.
38+
- `git checkout <branch_name>` - go to branch `<branch_name>`.
39+
- `git branch` - check which local branches you have and where you are (in green).
40+
- `git push origin <branch_name>` - push (upload) your local changes in your current branch into the branch named `branch_name` in your github repository.
41+
42+
### Extras
43+
44+
Commands we didn't use in class but that might be useful for you:
45+
46+
- `git pull origin <branch_name>` - pull (download) your changes from your github repository in the branch named `<branch_name>`, into your current local branch.
47+
- `git checkout --file <file_name>` - use if you changed the file named `file_name` and want to revert the changes, i.e. to get back the version you had in the last commit
48+
- git
49+
50+
**_Notes_**
51+
52+
For the sake of consistency (and to avoid mistakes), make sure that when you push you do it to a branch with the same name as the branch where you are, e.g. if you are on a branch named `my_homework` then push to a branch named `my_homework` by typing `git push origin my_homework`.
53+
54+
When pulling, if you want to pull from a branch named, for instance `git_homework`, make sure that you are in a branch with the same name (`git_homework`) on your computer as well, and only then do `git pull origin <branch_name>`.

legacy/git/git1/class_exercises.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Class exercises
2+
3+
## Exercise 1
4+
5+
We will use the homework repository and the branch `main`.
6+
7+
It will be your own individual repository or the central homework repository of your class - depending on which approach you are using in your class.
8+
9+
1. clone the homework repository into your computer.
10+
2. when you are on `main` branch, create a branch named `git-week1/exercise_1/<yourname>`\* and move to it;
11+
3. create a folder named `class_playground` in the `git` folder, under `/week1`;
12+
4. create the following files inside the `class_playground` folder: `apples_file.txt`, `bananas_file.txt`, `oranges_file.txt`;
13+
5. add some text to each of the files;
14+
6. add and commit the `apples_file.txt`;
15+
7. add and commit both the `oranges_file.txt` and the `bananas_file.txt`;
16+
8. add more text to the `apples_file.txt`;
17+
9. add and commit the changes in the `apples_file.txt`;
18+
10. push your changes to Github.
19+
11. go to the branch on github and look at the commits, analyze and discuss how it looks and how it connects with what you just did.
20+
21+
`*` `<yourname>` should be replace by your actual name, f.x. `git/week1/exercise_1/maria`
22+
23+
## Exercise 2
24+
25+
The goal of this exercise is to practice the homework workflow.
26+
It will basically follow the second part of the class videos.
27+
28+
1. when you are on `main` branch, create a branch named `git-week1/exercise_2/<yourname>`\* and move to it;
29+
2. create a file named `my_homework.txt` in the `git` folder, under `/week1/class_playground`;
30+
3. add some text to the `my_homework.txt` file;
31+
4. add and commit the changes in the `my_homework.txt` file;
32+
5. add more text to the `my_homework.txt` file;
33+
6. add and commit the changes in the `my_homework.txt` file;
34+
7. push your changes to github;
35+
8. on github, create a pull request from the exercis branch to `main`;
36+
9. on your computer add some more text to the `my_homework.txt` file;
37+
10. on your computer, add and commit the changes in the `my_homework.txt` file;
38+
11. push the changes to github;
39+
12. on github, check what happened to the pull request you created in step 8.
40+
13. if you are on an individual homework repository approach, merge the PR and proceed to the next step. If you are on a central homework repository approach, DO NOT merge the PR, and skip the next step.
41+
14. go to the `main` branch and update `main` by "downloading" the new commits from github: `git pull origin main`.
42+
43+
`*` `<yourname>` should be replace by your actual name, f.x. `git/week1/exercise_2/maria`
44+
45+
## Exercise 3
46+
47+
In this exercise, you will get an error when pushing to github and you will have to solve it.
48+
49+
1. on your homework repo go to the branch `main`, create a branch `git-week1/exercise_3/<yourname>`\* and move to it;
50+
2. in the `git` folder, under `/week1/class_playground`, create a file named `colors.txt`;
51+
3. add two colors to the file `colors.txt`, one per line;
52+
4. add and commit the changes in the `colors.txt` file;
53+
5. push the branch `git_exercise_3` to github.
54+
6. **on github**, go to the branch `git_exercise_3` and add a color in the last line of the file `colors.txt`, commit your changes;
55+
7. **on your computer**, add a color in the first line of the file `colors.txt`, add and commit your changes;
56+
8. push the branch `git_exercise_3` to github. Discuss what is happening and how to solve it.
57+
58+
`*` `<yourname>` should be replace by your actual name, f.x. `git/week1/exercise_3/maria`
59+
60+
## Exercise 4
61+
62+
In this exercise you will get in trouble by checking out from the wrong branch you will have to solve it.
63+
64+
1. on your homework repo **DON'T** go to the main branch, make sure to stay on the branch from the previous exercise.
65+
2. create a branch `git/week1/exercise_4/<yourname>`\* and move to it;
66+
3. in the `git` folder, under `/week1/class_playground`, create a file named `movies.txt`;
67+
4. add two movie names to the file `movies.txt`, one per line;
68+
5. add and commit the changes in the `movies.txt` file;
69+
6. push the branch `git_exercise_4` to github.
70+
7. on github, create a pull request from your new branch to `main`.
71+
8. see what commits you have there - do you only have commits from this exercise? Do you have commits that should not be here? Discuss why it happened and how to solve this situation.
72+
73+
`*` `<yourname>` should be replace by your actual name, f.x. `git/week1/exercise_4/maria`
74+
75+
## Exercise 5
76+
77+
The goal of this exercise is to get more familiar with branches.
78+
79+
Take notes of the answers to the questions in points 14, 15, 16, 17, 18, 19, 22, 23, 25, and 26. Discuss the answers in your breakout room.
80+
81+
1. create a new folder in your Desktop called `branch_exercise`;
82+
2. using the command line go to that folder and create a new repository there (`git init`);
83+
3. create a new file in that folder called `countries.txt`;
84+
4. add two country names (one per line) to the `countries.txt` file;
85+
5. commit your changes;
86+
6. create a new branch named `add_countries`, move to that branch;
87+
7. add two more country names (one per line) to the `countries.txt` file;
88+
8. commit your changes;
89+
9. go back to `main`;
90+
10. create a new branch named `add_cities`, move to that branch;
91+
11. create a new file named `cities.txt`;
92+
12. add two city names (one per line) to the `cities.txt` file;
93+
13. commit your changes;
94+
14. go back to `main` and take a look around your folder. Which files do you see? What are their contents?
95+
15. do `git log --oneline`. Which commits do you see?
96+
16. go to the `add_countries` branch and take a look around your folder. Which files do you see? What are their contents?
97+
17. do `git log --oneline`. Which commits do you see?
98+
18. go to the `add_cities` branch and again take a look around your folder. Which files do you see? What are their contents?
99+
19. do git `log --oneline`. Which commits do you see?
100+
20. now go to `main`;
101+
21. merge the branch `add_countries` with main (`git merge add_countries`);
102+
22. take a look at your folder, which files do you see? What are their contents?
103+
23. do `git log --oneline`. Which commits do you see?
104+
24. now merge the branch `add_cities` with main (`git merge add_cities`)
105+
25. take a look at your folder, which files do you see? What are their contents?
106+
26. do `git log --oneline`. Which commits do you see?

legacy/git/git1/homework.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Homework
2+
3+
## Exercise 1
4+
5+
In this exercise you will get some practice submitting your homework by pushing it to Github and then creating a pull request.
6+
You will be using this workflow every week to submit your homeworks, so it's important that you get comfortable with it.
7+
You will also practice adding/commiting files one by one.
8+
9+
You will use the your class homework repository on your computer to do the exercise. Here are the instructions:
10+
11+
1. Go to your class homework repo on your computer (you would have already cloned it in preparation or in class exercises)
12+
2. Go to branch `main`
13+
3. Pull the latest changes to make sure your local `main` is up to date
14+
4. Create a branch for your homework, named `git-week1/yourname`, and move to that branch
15+
5. Inside the folder `git/week1` create 3 new files:
16+
- a file named `my_favorite_food.txt`, inside the file write your favorite food recipe (you can just find a random recipe on google and paste it in the file ;)
17+
- a file named `my_second_favorite_food.txt`, inside the file write the recipe for your second favorite food
18+
- a file named `countries.txt`, where you list three countries that you have visited (this doesn't need to be true, you can just write the names of three random countries)
19+
6. Add and commit the file `my_favorite_food.txt`;
20+
7. Add and commit the file `my_second_favorite_food.txt`;
21+
8. Add and commit the file `countries.txt`;
22+
9. Push your changes into your class homework repository on Github.
23+
10. Go to Github and create a pull request (PR) from the branch `git-week1/yourname` to `main`
24+
25+
## Exercise 2
26+
27+
You have hopefully recieved a review on your last week html-css homework.
28+
If you submitted it later into the week, you might not have a review yet, in that case - wait. Be faster next time :).
29+
If you submitted the homework too late, you are not entitled to a review, but you can still try and ask for one.
30+
31+
1. go to your local copy of the class homework repo, `main` branch;
32+
2. update the `main` branch with the latest changes in the origin;
33+
3. checkout to your `html-css` homework branch;
34+
4. merge `main` into this branch;
35+
5. make changes to your `html-css` homework as adviced by mentors in your homework review and/or make any other changes or improvements;
36+
6. commit and push the changes to the branch in origin;
37+
7. close the `html-css` homework PR.
38+
39+
## Cheat sheet / tips
40+
41+
Commands that you will need:
42+
43+
- `git branch <branch-name>` - to create a new branch named `<branch-name>`
44+
- `git checkout <branch-name>` - to move to a branch named `<branch-name>`
45+
- `git add <file_name>` - tell git to start tracking a file and to update what will be commited
46+
- `git commit -m "commit_message"` - commit (save) your changes
47+
- `git push origin <branch-name>` - push (upload) your changes in your current branch to your github repository into the branch named `<branch-name>`.
48+
49+
**_Note_**
50+
For the sake of consistency (and to avoid mistakes), make sure that when you push you do it to a branch with the same name as the branch where you are, e.g. if you are on a branch named `git-week1` then push to a branch named `git-week1` by typing `git push origin git-week1`.
51+
52+
When pulling, if you want to pull from a branch named, for instance `main`, make sure that you are in a branch with the same name (`main`) on your computer as well, and only then do `git pull origin <branch-name>`.
53+
54+
Other useful git commands:
55+
56+
- `git status` - remember, it is your best friend, it tells you what is the state of your repository and sometimes what you should do.
57+
- `git branch` - this is your second best friend, it tells you in which branch you are (you can also see where you are when you do `git status`)
58+
- `git log`
59+
- `git log --oneline`
60+
- `git pull origin <branch-name>` - pull (download) your changes from your github repository in the branch named `<branch-name>`, into your current local branch.
61+
62+
Command line commands that might be useful:
63+
64+
- `pwd`- print working directory, to know where you are
65+
- `cd <folder_name>` - to go inside a folder named `<folder_name>`
66+
- `cd ..`- to go to the parent folder of your current folder
67+
- `mkdir <folder_name>` - to create a new folder
68+
- `ls`- list all the folder contents
69+
- `ls .*` - list all the folder contents, also invisible folders/files (e.g. the git folder)

0 commit comments

Comments
 (0)