![]() ![]() To start working on the branch and adding commits to it, you need to select the branch using git checkout: git checkout cool-feature If the branch with the same name already exists, you will see the following error message: fatal: A branch named 'cool-feature' already exists. For example, to create a new branch named cool-feature, you would type: git branch cool-feature To create a new local branch, use the git branch command followed by the name of the new branch. git branch -r Creating a Git Branch #Ĭreating a new branch is nothing more than creating a pointer to a given commit. The -r option tels Git to list only the remote branches. ![]() If you want to list both local and remote branches pass the -a option: git branch -a dev In Git, local and remote branches are separate objects. In this example, that is the master branch. The current branch is highlighted with an asterisk *. To list all local Git branches use the git branch or git branch -list command: git branch dev This article explains how to create and list local and remote Git branches. When fixing a bug or working on a new feature, developers are creating a new branch that later can be merged into the main codebase. Branches are essentially pointers to a certain commit. Branches are part of the software development process and one of the most powerful features in Git. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |