$ git branch -d dummyĮrror: The branch 'dummy' is not fully merged. This will permanently delete all the unmerged changes that were made to the branch. To forcefully delete a branch we use the git branch -D command. ![]() Git will not allow us to delete a branch if it has unmerged changes. The git branch -d command is a "safe" command. In the above output we can see that there are 3 branches. To delete a branch we use the git branch -d command. Now, if we commit changes using the git add and git commit commands then it will be saved in the dev branch as we are currently on it. In the above example we are switching to the dev branch. ![]() To checkout a branch we use the git checkout command. To start committing changes to a new branch we have to first jump (switch) on it. Now, if we list the branches we will see two names. The above image represents the master and dev branch. The above command creates a new branch called dev and a new pointer pointing at the last commit. To create a new branch we use the git branch command. The above output tells us that there is only one branch master and the * denotes that we are currently on it. To list all the branches we use the git branch command. In the above image we have a master branch and a pointer pointing at the last commit.Īll changes committed using the git commit command is saved in the branch we are currently on. ![]() Generally a project has multiple branches like master, testing, dev1, dev2 and so on. The first branch that we get when we create a Git repository is called the master branch.Ĭommonly, the master branch holds the production code, the one running in the production environment and your users are interacting with it.ĭevelopment work is generally done in a separate dev branch which is later merged with the master branch when they are ready for production server. What is a branch?Ī branch in Git represents an independent line of development having its own working directory, stagging area and committed project history. In this tutorial we will learn about branches in Git.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |