

These commands, again, are used to work with local branches. In case you'd like to rename a different local branch (which is NOT currently checked out), you'll have to provide the old and the new name: $ git branch -m If you want to rename your current HEAD branch, you can use the following command: $ git branch -m That's why Git makes it pretty easy to rename a local branch. Mistyping a branch's name or simply changing your mind after the fact is all too easy. "Creating" branches in a remote repository happens by publishing an existing local branch - which we'll talk about later. It goes without saying that you can only create new branches in your local repository. If you'd like your new branch to start at a specific revision, you can simply add the revision's SHA-1 hash: $ git branch 89a2faad When providing just a name to the git branch command, Git will assume that you want to start your new branch based on your currently checked out revision.
#Git create branch how to#
So let's start by talking about how to create branches: $ git branch Here's an overview of what we're going to cover:īefore you can work with branches, you need to have some in your repository. But I will provide links if you want to learn more. I didn't want to produce a book-length article, so I won't go into detail for all of the actions. My intention with this post is to create a comprehensive overview of the things you can do with branches in Git.

You can create and delete them, rename and publish them, switch and compare them.

And there's an endless amount of things you can do with them. Branches are one of the core concepts in Git.
