Practical Git via GitExtensions
  • Git - a Distributed System
  • Bare Minimal Configurations
  • Creating a New Branch
  • Making a Commit
    • Adding only a portion of a file
    • Commit Message
    • Cherry-pick
    • Revert
  • Rewriting History
    • Rewording the Last Commit
    • Rewording Commit Message in Middle
    • Editing the Last Commit
    • Squashing Last Few Commits
    • Squashing Commits in Middle
    • Spliting Commit into Multiple
    • Removing a Commit
    • Pushing after Rewriting History
  • Lost and Found
  • Comparing Commits or Branches
  • Checking out a Branch into Another Folder
  • Blaming History
    • Blame
    • Bisect
  • Disabling Auto Tracking Branch
  • Line Ending
  • Ignore Unwanted Files
Powered by GitBook
On this page

Was this helpful?

Creating a New Branch

PreviousBare Minimal ConfigurationsNextMaking a Commit

Last updated 6 years ago

Was this helpful?

See ​

Command line

git checkout -b <BranchName> [origin/<RemoteBranchName>]​
git checkout -b <BranchName> [CommitOrRef]
​git branch <BranchName> [CommitOrRef]

Create on top of remote branch instead of local

Most of time we'd like to create our branch basing on the remote branch for example origin/master, instead of a local master. A local master branch is only needed when we want to push something directly to the remote master. If commits are meant to be merged through pull requests, we can delete it to avoid inadvertently push to the remote master branch.

Fetch before creating

Most of time we'd like to fetch the remote branch first before creating branch, because the origin/master on our PC might not be up to date as the branch on remote server.

Fetch & Create in one go

In the left branch tree panel, find the remote branch, right click and select the menu Fetch & Checkout if want to use the same name as the local branch name or Fetch & Create Branch if a different name needed.

https://git-extensions-documentation.readthedocs.io/en/latest/branches.html#create-branch