Version Control
Check this guide (opens in a new tab) to learn more about version control using Git.
Git
Git is a distributed version control system (DVCS) that tracks changes in any set of computer files, usually used for coordinating work among programmers who are collaboratively developing source code during software development. It was originally authored in 2005 for the development of the Linux kernel.1
There are other version control tools and systems such as Mercurial (opens in a new tab), Subversion (opens in a new tab), Helix (opens in a new tab), Sapling (opens in a new tab), Bazaar (opens in a new tab), and Team Foundation Server (opens in a new tab), each with specific and general use cases. Git is the most popular and is integrated into almost every IDE out there. A comprehensive list of GUI clients is available here (opens in a new tab).
Commands
A selection of porcelain Git commands with corresponding tutorials to get started:
git init
(opens in a new tab)git clone
(opens in a new tab)git config
(opens in a new tab)git fetch
(opens in a new tab)git pull
(opens in a new tab)git add
(opens in a new tab)git commit
(opens in a new tab)git push
(opens in a new tab)git status
(opens in a new tab)git diff
(opens in a new tab)git rebase
(opens in a new tab)git stash
(opens in a new tab)git branch
(opens in a new tab)git merge
(opens in a new tab)git remote
(opens in a new tab)git checkout
(opens in a new tab)git reset
(opens in a new tab)git revert
(opens in a new tab)git clean
(opens in a new tab)git rm
(opens in a new tab)git log
(opens in a new tab)git tag
(opens in a new tab)git blame
(opens in a new tab)git lfs
(opens in a new tab)
A cheat sheet of Git commands from Atlassian is available here (opens in a new tab).
Collaboration
- Create a GitHub (opens in a new tab) account, if you do not have one already, and sign up for the GitHub Student Developer Pack (opens in a new tab).
- Install Git (opens in a new tab) and GitHub Desktop (opens in a new tab), if needed.
- Login with your GitHub credentials using GitHub Desktop/Visual Studio Code/IntelliJ IDEA.
Individual Repository
- Join the GitHub Classroom invitation (opens in a new tab) to create your individual private repository.
- Name your repository using the following format
section-username-firstname
, for example,b00-dd0123456-dane
. - Clone [
git clone
] your individual repository locally using GitHub Desktop/Visual Studio Code/IntelliJ IDEA. - Stage [
git add
] your changes. - Commit [
git commit
] your staged changes locally using a descriptive and concise message. - Push [
git push
] your changes to sync them with the remote repository. - Use this process to practice and push your weekly exercises.
Team Repository
- Join the GitHub Classroom invitation (opens in a new tab) to create/join your team private repository.
- Name your team repository using the following format
team-teamname
, for example,team-plasma
. - Clone [
git clone
] your team repository locally using GitHub Desktop/Visual Studio Code/IntelliJ IDEA. - Fetch [
git fetch
] to receive the latest changes. - Pull [
git pull
] to apply the changes to your working copy. - Stage [
git add
] your changes. - Commit [
git commit
) your staged changes locally using a descriptive and concise message. - Push [
git push
] your changes to sync them with the remote repository. - Use this process to collaborate on your project.
You must push before deadlines as commit dates can be overridden using git commit --date="YYYY-MM-DD HH:MM:SS"
.
Workflows
- Centralized workflow (opens in a new tab)
- Feature branching (opens in a new tab)
- Gitflow workflow (opens in a new tab)2
- Forking workflow (opens in a new tab)
We will be using the centralized workflow for the project, but feel free to explore other workflows and mix and match them to suit your preferences.
“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” —Martin Fowler (opens in a new tab)
Resources
- Getting Git right (opens in a new tab), Git merge conflicts (opens in a new tab), Git merge strategy (opens in a new tab), Merging vs. rebasing (opens in a new tab)
- Learn the basics of GitHub (opens in a new tab)
- An Introduction to Git (opens in a new tab)
- Pro Git (opens in a new tab)
- Generating a new SSH key and adding it to the ssh-agent (opens in a new tab)
- Adding a new SSH key to your GitHub account (opens in a new tab)
- Collaborating with pull requests (opens in a new tab)
- GitHub Code Review (opens in a new tab), How to improve code with code reviews (opens in a new tab)
- Understanding GitHub Actions (opens in a new tab)
- A look into how I manage my personal projects (my Git/GitHub workflow) (opens in a new tab)
- Monorepos (opens in a new tab), Monorepos in Git (opens in a new tab)
- Misconceptions about monorepos: Monorepo != monolith (opens in a new tab)