MCS 275 Spring 2024
Emily Dumas
Reminders and announcements:
We really talked about collaboration, and the possibility of a failed git push
.
Resolve the failed push.
Work on the game and talk about git branches.
You can have multiple lines of development underway at once, each with their own name and history. You can switch between them at will.
A repo starts with one branch called main
.
Each branch is just a pointer to its latest commit.
Branches are local by default but can also be shared.
git checkout -b my_branch_name
– Create new branchgit checkout my_branch_name
– Switch to existing branchgit checkout main
– Switch to the main branchgit branch -d my_branch_name
– Delete a branchgit commit
– commit staged stuff to active branchgit push origin my_branch_name
– push a branch to remote (default is to keep them local)Often projects keep main
clean (e.g. working!), and do all work on changes in branches.
One branch per feature (or task) is common.
This way, features can be worked on in parallel.
Branches "end" in two ways:
To merge alpha
into beta
, ending alpha
:
git checkout beta
git merge alpha
The merge is a commit to beta
.