January 24, 2021
Git feature branches are a workflow that involves creating separate branches for each feature you want to build. When a feature is finished, it gets merged into the central
This enables multiple features to be built in parallel on different branches, without overlapping over each other.
It also allows you to maintain a stable
master branch in case the feature gets thrown away or starts to ruin everything.
First make sure you're on the
master branch (if not, run
git checkout master to switch to it).
Then, create a new branch from
master and switch onto it (replace
<feature_branch>with the name you choose for your feature branch).
git checkout -b <feature_branch>
From here, you can do all your work as you would usually. Commit and push new changes for the feature to this new branch.
Once you're done with the your work on the branch and want to merge it into
master, run these four commands:
git checkout master git pull origin master git merge <feature_branch_name> git push origin master
<feature_branch>with your branch's name)
Afterwards, you'll probably want to delete the feature branch. These two commands first delete the branch on the remote host, then delete the branch locally.
git push -d origin <feature_branch> git branch -d <feature_branch>
A quick favor: was anything I wrote incorrect or misspelled, or do you still have questions? Please use this form to let me know or ask for help!