Git and GitHub
Luke Marsden, UNIS
(data.nleg@unis.no)
What is version control and why use it?
shopping_list.txt
Max
Tom
Why use GitHub?
shopping_list.txt
*Adam could be anyone
Max
Tom
Adam
Downloading Git
Using Git Bash
Create repository
1. From GitHub
Create repository
1. From GitHub
shoppinglist
shopping_list.txt
README.md
Create repository
2. Locally and
upload
shopping_list.txt
shoppinglist2
README.md
Create repository
2. Locally and
upload
Commits
C0
C1
Added pizza to shopping list
main*
Initial commit
shopping_list.txt
shoppinglist
README.md
Pushing
shopping_list.txt
shoppinglist
README.md
C0
C1
local main*
remote main
ID of commit
ID of parent commit
Branch name
Making changes on GitHub
Pulling
shopping_list.txt
shoppinglist
README.md
C0
C1
local main*
remote main
C2
Branches
shopping_list.txt
shoppinglist
README.md
C0
C1
C2
main*
newBranch
C3
main
newBranch*
Merging branches
C0
C1
C2
shopping_list.txt
shoppinglist
README.md
C3
main
newBranch*
main*
newBranch
C4
Two people working at same time
C0
C1
C3
C2
main*
newBranch1*
newBranch2*
main
newBranch1*
newBranch2*
main
newBranch1*
main
main
newBranch2*
C4
newBranch1
main*
newBranch1
newBranch2
From newBranch2
From main (HEAD denotes current branch)
Common to both
main
C5
newBranch2
Diff
Pull requests
C0
C1
local main*
main
main
newBranch*
local
remote
C2
main
newBranch*
newBranch
Pull requests
Forks and pull requests
Forks and pull requests
What to include in a README
Final remarks
Pull from origin (GitHub) before you start to update your local repository.
Push and pull regularly, especially if multiple users of repository.
Don’t work on main branch, create new one then merge or submit pull request.
This is just an introduction
There is SO much help online
My favourite visual, interactive way to learn git branching and version control: