This repository has been archived on 2023-11-08. You can view files and clone it, but cannot push or open issues or pull requests.
How-To-Git-Started/README.md

127 lines
2.9 KiB
Markdown
Raw Normal View History

2020-01-08 13:52:06 +01:00
# How to Git started
## Using a GUI
2020-01-08 16:46:22 +01:00
You can use any GUI for git, the ones we use are Fork and Sourcetree
You can download these at https://www.sourcetreeapp.com/ and https://git-fork.com/
2020-01-08 16:46:22 +01:00
For other GUIs check out https://git-scm.com/downloads/guis/
2020-01-08 16:53:05 +01:00
### Assignments
Assignment 1: Create a repository
1 Create your own new repository
2 Add a .gitignore file
3 Why you would like a gitignore file
4 Not pushing sensitive files
5 Not pushing environment files
6 Add a README
Assignment 2: Your first commit
Clone repository
Edit README file
Create a new file(s) and add information
Stage README and your file(s)
Commit README and your file(s)
Assignment 3: Merge conflicts
Go to the How to Git started repository
Add factorial.py and fibonacci.py to your repository
Choose a partner
Add him/her as a collaborator
Make the partner clone your repository
Let both of you edit the same line in the code file
Let one of you stage and push the changes
Solve the merge conflict
Assignment 5: Branching
Go to the How to Git started repository
Add index.html to your shared repository.
Let person A create a new branch called header
Let person B create a new branch called footer
Let person A edit the header of index.html
Let person B edit the footer of index.html
Stage and push the changes
Pull the latest changes
Track the branch of your partner
Assignment 6: Merge branches
Go to your master branch
Merge it with the header branch
Commit the merge
Merge it with the footer branch
Commit the merge
Push the changes
Delete your old branches
Assignment 7: Pull requests
Let one of you create a new repository (do not add collaborators)
Stage and commit a file
Let the other person fork the repository and clone it
Let him/her change the file and push it
Let him/her create a new pull request via the GUI
Let the other approve and merge the request
Let the other pull the latest changes
Assignment 8: Undo commit
Check the logs
2020-01-08 16:49:24 +01:00
### Learning objectives
- Introduction to VCS
- Create new repository
- Git ignore file
- Staging
- Committing
- Git push
- Git pull request
- Branching
- Merge / Rebase
- Undoing Commits & Changes
- Tag ?
- Log ?
## Using the terminal
### Getting started
2020-01-08 13:52:06 +01:00
Set up your git info
2020-01-08 13:55:14 +01:00
```shell
2020-01-08 13:52:06 +01:00
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
```
If you want to save your https credentials run
2020-01-08 13:55:14 +01:00
```shell
2020-01-08 13:52:06 +01:00
git config --global credential.helper store
2020-01-08 13:54:15 +01:00
Omit --global to set the identity only in this repository.
2020-01-08 13:52:06 +01:00
```
2020-01-08 16:54:53 +01:00
Or you can add an SSH key
2020-01-08 14:03:33 +01:00
## Saving changes
unstage by using
```shell
use "git reset HEAD <file>..." to unstage
```
2020-01-08 14:52:55 +01:00
Track remote branch
```shell
git checkout --track origin/<branch>
```
Delete remote branch
```shell
git push <remote_name> --delete <branch_name>
git remote prune <remote_name>
```