Branches allow you to work on, or add special features, without interfering with your current project. When you start a repository in Git, it is automatically assigned to the role of 'main' branch.
I often make another branch to work on the layout while I am building my site. I call it layout. Once I am pleased with my work I merge it with the 'main' branch.
To start in your terminal type in:
This will give you a list of current branches in your project. The branch you are currently working on will be highlighted. To make a new branch:
Then to switch over to your new branch type in:
Now you are working on your new branch. Once you have made some changes you go through the same process of:
You can also combine the commands:
If it is your first time pushing this branch to your remote repository then use:
Once you are finished pushing your changes to GitHub, then you can switch back to main by typing in:
Once you have switched to the main branch, you can then merge your other branch to main by typing in:
Now you have merged your changes from your other branch in with the main.
back to top