Lecture 25
College of Idaho
CSCI 2025 - Winter 2026
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
It’s like having a time machine for your code!
Git is a free and open source distributed version control system.
GitHub is a web-based hosting service for version control using Git. It’s a place to store your code and collaborate with others.
The basic Git workflow looks like this:
git clonegit clone is used to create a local copy of a remote repository.
You can find the repository URL on the GitHub page for the repository.
git addgit add is used to stage changes for the next commit.
Staging is an intermediate step before committing. It allows you to choose which changes you want to include in the next commit.
git commitgit commit is used to save your staged changes to the local repository.
Commit messages are important! They should be a short, descriptive summary of the changes you made.
git pushgit push is used to send your committed changes to a remote repository.
This is how you share your work with others and back it up to GitHub.
git pullgit pull is used to fetch and download content from a remote repository and immediately update the local repository to match that content.
It’s a good practice to pull changes from the remote repository before you start working to make sure you have the latest version of the code.
git branchgit branch is used to create, list, or delete branches.
# Create a new branch
git branch <branch-name>
# Switch to the new branch
git checkout <branch-name>
# Create and switch to a new branch in one command
git checkout -b <branch-name>Branches allow you to work on new features or bug fixes without affecting the main codebase.
git mergegit merge is used to join two or more development histories together.
# Switch to the branch you want to merge into
git checkout main
# Merge the other branch into the current branch
git merge <branch-name>This is how you integrate changes from a feature branch into the main branch.
A pull request is a way to propose changes to a repository. It’s a feature of GitHub, not Git.
It allows you to tell others about changes you’ve pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.