Version Control with Git
Git is a version control system used for tracking changes in source code during software development. Git is designed for coordinating work among multiple developers but it also enables powerful workflows on personal projects. When using Git you can keep track of why changes were made to your code, revert your entire project or individual files back to previous states, develop multiple features in parallel on separate branches and much more.
There are many different clients you can use to interface with git. There is a command line interface as well as many third party guis. In this class we will be teaching students how to use Github Desktop, but any git client should be sufficient for the course.
Github Desktop
Installation
We recommend downloading Github Desktop from https://desktop.github.com/. If you already use a package manager you can install using choco install github-desktop
or brew cask install github
.
Getting Started
- Sign in to github.com with your personal github account. Do not sign in to github enterprise server.
- Configure git with your name and the email address you have associated with your github account. The email address does not have to be your MIT email.
- If this is your first time using git we recommend following the getting started with github desktop tutorial. Please let us know if you have trouble with any of the steps.
For an overview of common tasks and how to do them with github desktop checkout contributing to projects tutorial.
Essential Workflow
- clone or fork a repository from github
- clone a repository using github desktop
- clone a repository to github desktop
- add files you have changed and commit them to your project
- committing and reviewing changes
Tips
- Commit early and often.
- It is generally good practice to make small iterative changes when writing software. If you follow this practice and commit your changes you will have a nice linear log of your project's progression which is easily searchable and revertable.
- Don't be afraid to branch when experimenting
- If you are making larger changes, you can create a branch and commit smaller changes to that branch. If you like the larger change you can merge it into your
main
branch. If you dislike the larger change you can easily revert back to where you were by checking out yourmain
branch again.
Github Student Developer Pack
We highly recommend signing up for the Github Student Developer Pack. The pack offers free access to a wide variety of developer-tools .
Helpful Git Resources
- A grip on git is a beautiful visual explanation of how git works from the inside out.
- Missing Semester Git Lecture is a great text explanation of how git works from the IAP class on developer tools.
- Learn Git Branching is a great online interactive tutorial for learning the git command line.
- GitHub Cheat Sheet This cheat sheet features the most important and commonly used Git commands for easy reference.