Version Control (Git) Prep
Overview
Version control is a vital tool when working with a team on software. While there are several different tools that support version control, Git is the most popular and widely used today. Today we’ll focus on learning the most important functionalities of Git.
Basic Learning Objectives
Before class, you should be able to:
- Explain what a code repository is and why we use code repositories.
- Explain the basic git workflow, so that you are ready to complete the git lab.
- Identify the circumstances which lead to merge conflicts
- Explain the basic strategies to resolve merge conflicts when they arise
Advanced Learning Objectives
After class, you should be able to:
- Add, change, and remove files from a git repository
- Create and resolve merge conflicts in your own and team git repositories
- Work with branches and merge branches
- Have your team repository setup
Readings
To achieve the basic learning objectives, you should read the following before class:
-
“Learn the basics of git in under 10 minutes”: Read only up to Step 0; we’ll be adding to our repos a bit differently.
-
“Git for dummies”: Read the whole thing. Note that you’ll be contributing to your own project, so we will not be dealing with pull requests. (In other words, “git push origin main” is exactly what I’ll be expecting you to do.)
-
“How do I git? Three ways to solve a merge conflict”. Read the introduction and “Method 2::Using the command line”. (Since we’re not dealing with pull requests, Method 1 does not apply, and Method 3 only applies if you want to use Git Desktop.)
Checks
Write answers to the following and bring them to class:
- What is git? What is its purpose?
- What is the difference between git and GitHub?
- What is a repository?
- What is the difference between a stage and a working directory?
- What is the typical git workflow, from start to finish, when you want to add or modify a file in a repository and make sure the changes are on GitHub?
- What is a merge conflict?
- Describe a situation in which a merge conflict might occur.
- What are the markers in a file that indicate where the conflict is?
- Describe the workflow you would use to resolve a merge conflict (i.e. what sequence of git commands would you use?).