# Git
# Reasons to use version control
- Have a record of what, when, whom and why you did something
- Snapshots of different development states
- Compare different versions of files
- Easily share work with others
- Integrate changes from others (merging)
- Mark finished product versions (tags)
- Try out new ideas (branches)
- Best practice and Industry standard
# Without Version Control
# Glossary
- Repository
- Stores complete history, branches, tags (and other meta-information)
- Working Copy
- Your “playground”, actual source code
- Commit / Revision
- A specific, single version/snapshot
- Branch
- A distinct line of development
# Distributed Version Control
- Every user has a full copy of the repository
- Repositories can be synchronized (push/fetch)
- Off-line access
# Git
- Started in 2005 by Linus Torvalds
- Used for Linux Kernel development - is still used
- Highly distributed
- Cryptographic integrity
# Install & Setup
- Install - https://www.git-scm.com
- Set user information
# Cheat Sheet
https://education.github.com/git-cheat-sheet-education.pdf
# Creating Repositories
- Create a new local repository
# Adding files
- ”staging”
- Adding new files
- Current state of the file is recorded
# Writing history
- Permanently save your work
- The seven rules of a great Git commit message
# Updating Files
- Tell Git about new changes
- Same thing as adding new files (Git only cares about the content of files)
# Browsing history
- Branch “master” == “main”
# Working copy status
- Shows list of modified, new and staged files
- Also reminds you of important commands
# Inspecting changes
- Show current changes
- Show differences between commits
- Show differences between branches
# What the fork?
- Try out new features
- In an ideal world: one branch per feature
- Branches are cheap, use them often
- Branches can be deleted
# Merging changes
- Integrate changes from a branch
- Integrate changes from others
# Merge conflicts
- Merges don’t always go well
- Git inserts conflict markers into conflicting files
git status
tells you the current state- Remove conflicts and add that state of the file with
git add
# Forking existing projects
- Get a copy of the repository
fetch
+merge
to update your copy
# Syncing changes
- Fetch downloads the latest changes from the remote repository
- With merge you can merge these changes with your local branch
pull
is a shortcut forfetch
+merge
push
uploads your local changes to the remote repository