Git Overview
What is Git?
Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows (thousands of parallel branches running on different systems).
- from Wikipedia
Why do we use it?
-
To download projects to our systems.
- Try cloning the following to a
read-only
directory in your workspace:$ git clone <clone-link>`
- After cloning is complete, you will need to
cd
into the directory.
- After cloning is complete, you will need to
- Example repos
- WBDV Winter 2022 website
- Font Awesome - a collection of openly-licensed icons
- Reveal JS - a framework for building slides in the browser
- Try cloning the following to a
-
Code backups: Git allows you to take snapshots of a directory (commits) which we can rollback to in case we royally screw up.
-
Syncing code: If you work on two machines, like a home laptop and office system, you can use Git to sync your projects.
-
Collaboration with teammates: Git allows multiple developers to work on the same file at the same time. Conflicts will happen but Git helps resolve them.
-
Deployment: In industry, we use Git to sync our project code with a server to make it live.
How does it work?
- At the end of the day, Git keeps track of each line of code in your project, including:
- who created it.
- every change made to it
- who made each of those changes and when
First-time Setup
- Install Git
- Set your identity
- Optional(?): Set up your SSH keys
Extras
-
-
merge conflicts often happen in team environments but this is an activity to help you practice resolving conflicts by yourself.
-
-
Pair programming with Git: Commit catch
Common Errors
-
Forgetting the
-m "commit message"
portion of a commit will openvim
(or whatever command line text editor is set up) and you'll see a screen like this:- If this happens, it's easiest to just quit
vim
by typing:q!
(see:vim
cheat sheet)
- If this happens, it's easiest to just quit