Introduction to Git

Why Git?
- Linux Kernel
- 15 million lines of code
- 60 000 contributors
- One central repository
- Was using SVN
- Very Slow
- Central point of failure

Originally Developed by Linus Torvalds
What is Git?
"Git is a Free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency."
Distributed

Github
- Github is not Git
- Cloud service
- Central repository. Although Git is decentralized
- Extra features on top of Git
- Pull requests
- Visualisations
- Permission management
- Organizations

Tools
- Command line
- Best way to do git. Most servers don't have a UI.
- Learn this first.
- Unix users. Add small script to bash_profile to show current working branch
- Source tree
- Drag-Drop UI
- Good visual overview
- Use it for the more complex interactions

SourceTree
Basic Concepts
-
Clone Make a local copy of a repository
- When you want to make changes to the existing repo.
-
Fork Make a clone of a repository. On github. Your own central version.
- When you want to create your own version of an existing software project.
- Git init Create a new repository from existing folder
- Remote: Link to an external repository

Local modification

- Git status
- Git add
- Git commit
- Git reset
- Git remove
Pushing and Pulling

Merge Conflicts


Branching & tagging

Git Stash

git stash
git stash pop
Undo Changes
- Never rewrite history
- Instead, use git revert
- commits the inverse
- Use git rebase carefully!

Git Flow
- Model on how to do branching
- Industry Standard
- For World of Balance
- Master - Latest Stable version
- Hotfixes - Merges straight into master
- Development - Unstable Branch
- Feature branches - sub branch of development for specific features. Very unstable.
Feature Branches
- Every independent feature has a branch
- Branched off of Development
- Create pull request when you want to merge
- Review with team before you merge

Pull Requests

Github Issues

Releases
- Merge Development into Master
- Increase the tag number (Semver)
- Should (in theory) be stable

Think about other developers
Some tips and guidelines

- Never Merge into dev without Pull Request
- Definitely do not merge into Master
- When in doubt, create a feature branch
- Whitespace vs tabs.
- Feel free to experiment on branches
- Write clear commit messages
- "Added a new animal class"
-
- "Changed some text in some file"
- Use Github issues to communicate across teams
- Be careful with merge conflicts. Use git blame
Some Golden rules
Incase of broken code

- This is why we have version control.
- Changes can always be reverted
Questions?
Copy of Intro to Git
By Jens Vanderhaeghe
Copy of Intro to Git
- 921