89.5 Git Branch
Creating a branch to work on a task or
issue is good practice. Here we create a local-only branch called
dev where we might do our local development. We will complete
the development, test it and then merge those local developments back
into the main branch. Finally we remove the local branch.
To create a new branch we simply ask git to
checkout the branch with a new name,
kayon/validator in this case. The
-b option will
create the branch and name it as such.
git checkout -b kayon/validator
We can list the branches careated using branch
$ git branch * kayon/validator main
To optionally register the branch with the remote repository so it is no longer simply a local branch:
git push origin kayon/validator
We now begin coding and committing to the branch. For example, if we have made changes relating to improving the messages generated by our code we might commit the changes with:
git commit -m "Improve messaging." user_interactions.py
If we have registered the branch we can then also push those changes to the remote repository:
When we have completed our development activities we will be ready to merge our changes into the main branch. First ensure we are on the main branch:
git checkout main
Then merge into the dev branch:
git merge dev
The mergetool command can be used to assist in the task of resolving any conflicts.
If the branch is no longer required we can delete the branch from the remote repository.
git branch -d dev
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0