84.5 Git Branch
20190415 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.
$ git checkout -b validator
We can list the branches careated using branch
$ git branch * validator main
To optionally register the branch with the remote repository so it is no longer simply a local branch:
$ git push origin 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:
$ git push
When we have completed our development activities we will be ready to merge our changes into the main branch.
$ git checkout main $ git merge dev
The mergetool command can be used to assist in the task of resolving any conflicts.
$ git mergetool
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 development 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-2021 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0.