Skip to content

Instantly share code, notes, and snippets.

@mtrefzer
Last active November 1, 2021 07:45
Show Gist options
  • Save mtrefzer/8a7347530371bc473b7d7e4595f01699 to your computer and use it in GitHub Desktop.
Save mtrefzer/8a7347530371bc473b7d7e4595f01699 to your computer and use it in GitHub Desktop.
git-use-feature-branch

Howto

Git: use feature branch

Create Branch and push (code should never exist in just one place).

$ git checkout -b feature-branch main          // creates a local branch for the new feature
$ git push origin feature-branch               // makes the new feature remotely available

Changes made to main should be merged back into the feature branch.

$ git merge main                             // merges changes from main into feature branch

When development on the feature is complete, the lead (or engineer in charge) should merge changes into main and then make sure the remote branch is deleted.

$ git checkout main                          // change to the main branch  
$ git merge --no-ff feature-branch           // makes sure to create a commit object during merge
$ git push origin main                       // push merge changes
$ git push origin :feature-branch              // deletes the remote branch
$ git push origin --delete feature-branch      // deletes the remote branch alternative syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment