Version Control with Git & GitHub
Piet Cordemans
Nico De Witte
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Version control manages changes
to a set of code/files over time
Babbel1996
(https://commons.wikimedia.org/wiki/File:Tardis_BBC_Television_Center.jpg),
„Tardis BBC Television Center“, CC BY 2.5
Version control allows
you to jump back and
forth through the
history of a set of
files, even exploring
alternative timelines
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Repository
Centralized Distributed
https://git-scm.com/
Command Line tool
Tell git who you are
> git config --global user.name "Firstname Lastname"
> git config --global user.email "name@example.com"
Set up
Repository
> git init
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Working
Copy
Commit
Each node is called a commit
Who?
When?
Why?
What?
Author: Chuck Norris
Date: Thu Feb 28 15:52:55 2019
Message: Chuck Norris only
tests in production
Added: prod/test
Removed: staging/test
Working Copy Staging area Repository
git add git commit
What is the current state?
> git status
Saving your changes
> git commit -m"describe what is committed in this message"
> git add .
.gitignore
Things you want to ignore
* Build artefacts
* Binaries
* Your mother-in-law
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Could you give me an overview?
> git log
What has changed?
> git diff
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
What if I forgot something to commit?
> git commit --amend
What if I didn't want to stage a file?
> git reset HEAD {{filename}}
What if I want to unmodify a file?
> git checkout --{{filename}}
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Local Remote
Adding a remote
> git remote add origin https://github.com/pcordemans/ChuckNorrisFacts
Local Remote
Local Remote
Pushing to a remote
> git push origin master
Where was that remote again?
> git remote -v
Cloning a repository
> git clone https://github.com/pcordemans/ChuckNorrisFacts
Local Remote
Retrieving the latest changes
Local Remote
> git pull
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Let's talk about Markdown
# This is Markdown
We love Git and GitHub
<h1>This is HTML</h1>
<p>We love Git and GitHub</p>
Actually, Markdown is extensively used by GitHub
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
Merge conflict:
Rather sooner than later, you will change
something, somebody has also changed
History is a graph
Branching Merging
master
The master branch
The current branch a.k.a. HEAD
master
HEAD
Jumping from one commit to another
WARNING: don't try to commit changes
master
HEAD
master> git checkout {{hash of the commit}}
Creating a new branch and jumping to it
master> git checkout -b dev
master
HEAD
Before After
master
HEAD dev
Committing to the new branch
dev> git commit -m"this message explains everything"
master
HEAD dev
Fast forwarding the master branch
Before After
master
HEAD dev
masterHEAD
dev
dev> git checkout master
master> git merge dev
Actual branching
master
HEAD devBefore After
master HEAD
dev
dev> git checkout master
master> git commit -m"descriptive message"
Merging
Before After
master HEAD
dev master HEADdev
master> git merge dev
Resolving merge conflicts:
Make a new commit after you figured out
what to keep and what to delete
Forking
GitHub:
source repository
GitHub:
fork
GitHub:
fork
Local
clone
GitHub:
Pull Request
Local
clone
What is Version Control?
Setting up a repository
Saving changes
Looking at history
Undoing changes
Distributing the repository
Structuring text
Collaboration
Beyond GitHub
GitHub is more than hosting remote git repositories
Project management
Collaboration
Education
Integration
Sharing
Security
Integration example
Netlify is website deployment service, which deploys
a website from a repository
https://workshop-iot-programming.devbit.be/git-and-github/
More information
https://git-scm.com/book/en/v2
https://www.atlassian.com/git/tutorials
IoT-Incubator.be
Research - Prototyping - Training
Contact us Research and education | Internet of Things
VIVES University of Applied Sciences | Industrial Sciences and Technology
Spoorwegstraat 12 | 8200 Brugge | BELGIUM
piet.cordemans@vives.be | IoT-Incubator.be
LoRa Academy
Internet of Things: Mbed
Cisco Academy
o CCNA
o Cybersecurity Operations
Ethical hacking
Training courses
App development
o NativeScript
o Node.js
DevOps
Wireshark
https://www.vives.be/nl/navormingen-ict

Version Control with Git & GitHub