How To Create A Branch in Git


This page will cover how to go about creating a new branch in your local git repository. Branches are useful in keeping different work separated without needing to create a bunch of working copies of the codebase.

Using TortiseGit(Windows only)

Tortisegit is a Windows shell-integrated git ui tool to make it easier to work with git. If you've used tortisesvn, it's pretty much the same but git-flavored instead. If you don't already have tortisegit, you can get it here

Creating a new branch

Once the engine is downloaded, we can create a new branch to pull a PR into to test it.
First, click the RMB and expand the "TortiseGit" option in the shell menu and find the "Create Branch" option


Click that and a new window will pop up


This allows us to create a new branch based off our current one(development). This way, we can compartmentalize any changes we make into a branch without affecting other changes we've made in different branches
To create a new branch, fill in the box next to the obviously named "New Branch" option, and give the new branch a name.

Usually you'd name the branch something associated to the changes happening, or if something is being tested, so you can easily tell them apart. We'll name the new branch "NewBranch".

Once that's done, click OK.

You can easily tell which branch we're on by clicking RMB and looking at the "Git Commit -> " option. That command is for commiting any changes we've made to the currently selected branch. In our case, it'll say "Git Commit -> "NewBranch"", because we just created and switched to our new branch.


You can now do whatever work you need to do and as long as you commit it to the branch, these changes will be retained in the branch history, even if you switch branches.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License