Even more important this semester
Keeps track of the history of changes
Allows branching of history
Lets us compare different branches.
Helps to merge branches back together
Make a feature branch
Make changes to files
Periodically commit changes to branch
Push (sync) branch to Github
Make a PR and request review
After PR approved, merge to main
Optionally, delete the feature branch
A named version of all the files in your repository
Different branches can have different contents
Allows you to work on different things without them interfering with each other.
In multi-person projects even more important.
Commits are how you save work in git.
You might make several changes in multiple files before you commit them.
Each time you make a commit, you will write a short description of the commit.
Each new commit is added to the current branch.
main
The main
branch is what its name says.
Ultimately we want all the code you write to end up in main
.
But code starts out in “feature branches”
Merging is the process of adding the commits made in one branch (usually a feature branch) to another branch (usually main
.)
If the changes don’t textually conflict, things merge automatically
That should almost always be the case for you.
A Github feature for looking at the changes you’ve made on one branch that you want to merge into another.
Allows reviewing, commenting, approval, etc.
The main mechanism for communicating about code in open source projects and many companies.
And in this class.
Name branches for the directory where the new code will live e.g. projects/whatever
This ensures that code from the projects/whatever
branch will never conflict with code from other project branches.
After you merge your feature branch PR to main
you can keep working on the same branch if you don’t delete it.
Or you can create a new branch with the same name if you did.
New PRs will only include the new changes.
Submit PRs for review regularly.
Merge PRs as soon as they are approved.
If I request changes, you should work on those things and re-request review.
Delete old branches when you are done with a project or putting it down for a while.
Don’t work on too many projects at once. Ideally one at a time.
You will spend more time working on projects than on problem sets.
To do your work you will have to deal with git and Github.
We are going to start using a new development environment called Codespaces that is provided by Github.