Git Tutorial
Arctos 6135
Basic Concepts
What is a Version Control System (VCS)?
What is Git?
≠
The Need For Git/VCS
Installation
Installation
If that doesn't fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of 'It's really pretty simple, just think of branches as...' and eventually you'll learn the commands that will fix everything.�Source: https://xkcd.com/1597/
For Windows Only:
Git Basics
Getting a Git Repository
Tracked vs Untracked Files
Tracked vs Untracked Files (contd.)
Checking File Status
Tracking and Staging Files
Tracking and Staging Files (contd.)
Commits (Snapshots)
Commits (Snapshots) (contd.)
Creating Commits
Writing Good Commit Messages
Merge branch 'asdfasjkfdlas/alkdjf' into sdkjfls-final�Source: https://xkcd.com/1296/
Viewing the Commit History
Viewing the Commit History (contd.)
The 3 Areas of Git
Undoing Things
Fixing Commit Mistakes
Un-modifying a Modified File
Undoing Commits - Method 1 (Revert)
Still Accessible
HEAD and master (References)
HEAD
master
Undoing Commits - Method 2 (Reset)
HEAD
master
HEAD
master
Inaccessible
Lost Forever*!
Hard, Soft and Mixed Resets
Undoing Commits - Method 3 (Checkout)
HEAD
master
HEAD
Still Accessible
Detached HEAD
Ignoring Files
What Files Should Not Be Tracked
The .gitignore File
.gitignore Syntax
.gitignore Syntax (contd.)
Ignoring Already Tracked Files
.gitignore Templates
Branching
What are Branches?
Branches in Git
master
branch1
Creating and Deleting Branches
HEAD
master
git branch newbranch
newbranch
Viewing Branches
Switching Between Branches
HEAD
master
git checkout newbranch
newbranch
HEAD
Switching Between Branches (contd.)
HEAD
master
git checkout -b newbranch
newbranch
HEAD
Branching Example
HEAD
master
git checkout -b newbranch
newbranch
HEAD
git commit
newbranch
HEAD
git checkout master
HEAD
master
Merging
What is Merging?
How to Merge Branches
*A merge commit will not be created if it’s a fast-forward (more on that later)
Fast-Forward Merges
master
git merge master
newbranch
HEAD
newbranch
HEAD
Merging Divergent Branches
master
newbranch
git merge newbranch
master
Merge Conflicts
Resolving Merge Conflicts
Resolving Merge Conflicts (contd.)
Merge Strategies
Remotes
What are Remotes?
Adding Remotes
Fetching From a Remote
Pulling From a Remote
Pushing to Remotes
Deleting Branches on a Remote
Remotes and Merge Conflicts
Force-Pushing
Tracking and Upstream Branches
Tagging
What are Tags?
HEAD
master
v1.0
HEAD
master
Lightweight vs Annotated Tags
Creating & Deleting Tags
Viewing Tags
Pushing & Deleting Tags in a Remote
Stashing
What are Stashes?
Using Stashes
Stash Messages
Stash Names & Hashes
The Branching Model/Workflow
What is a Branching Model/Workflow?
Our Branching Model
Our Branching Model (contd.)
A Note on Merging
master
develop
master
A Note on Merging
master
develop
master
GitHub
What is GitHub?
GitHub as a Remote
Creating a Repository
Issues
Issues (contd.)
Pull Requests
Pull Requests (contd.)
Forks and Contributing to Open Source
Works Cited
Works Cited