Skip to content

Creating branches and branch management

Mgonzalez-droid edited this page Oct 26, 2022 · 1 revision

0. Pull changes

You need to pull changes before creating new branches or you will be behind. Enter the following command then continue:

git pull

1. Switch to the branch you want to branch from:

Type in the following command in git bash or wsl, for example:

git checkout dev

2. Create Feature Branch

You will create a feature branch for the specific feature or thing you are working on. To create your branch enter the following command:

git checkout -b dev-featureName dev

*this command creates new branch and branches off of dev branch

3. Set your branch to be tracked remote

To have your branch show up on GitHub and allow others to work on it you have to set it upstream. Enter the following command while you are in your new branch:

git push --set-upstream origin dev-<feature-name>

4. Develop

Now you are good to go a simple command:

git push

Will push you changes to your remote feature branch and from GitHub you can create a pull request to merge your changes into your dev- branch as you complete your feature.

5. Delete Branch

If you want to delete your branch use the commands below to delete locally and remotely:

Local Delete: git branch -d dev-featurename

Remote Delete: git push origin --delete dev-featurename