Preface
I often see new and aspiring software developers who jump into field of software engineering from other disciplines find Git to be a scary subject and are afraid of it, with good reasons. Being afraid to break a git repository for a whole team is a good fear to have.
Git is used on daily basis during software development and it’s important to get comfortable with it to be able to get your work done. My aim with these small posts is to provide helpful daily usage tasks that should make those new developers comfortable.
These tutorials present a situation which you will find yourself in and provide command and explanation of what it does.
These of articles assume basic understanding of Git.
Situation: You need to start work on a task and need to create new branch
Create new branch command:
git pull
git checkout -b branchName
What does command do
You should perform a pull before git checkout to ensure you have the latest version of the branch you are branching off of.
You would normally start on “main” branch of your repository which means when you create your new branch it will be a copy of main branch at the time you created it.
The command not only creates a new branch with checkout -b but also it makes it active. This is a common practice as you often want to start working on newly created branch right away.
Note
main
branch sometimes is know by other names. It could be called anything else depending on organisation you work for and on history of that repository and company.