![]() If you try to do this, Git will show you an error:Īs the error suggests, you'll need to use the -D flag instead: git branch -D local_branch_name This is because the commits are not seen by any other branches and Git is protecting you from accidentaly losing any commit data. If the branch contains unmerged changes and unpushed commits, the -d flag will not allow the local branch to be deleted. The command for deleting a local branch that we just used doesn't work in all cases. #in my case the other branch I have is master, so I'd do: #where branch_name is the name of the branch you want to move to So before deleting a local branch, make sure to switch to another branch that you do NOT want to delete, with the git checkout command: git checkout branch_name If you try to do so, you'll get an error that will look something like this: I want to delete the test2 branch, but it is not possible to delete a branch you are currently in and viewing. I am currently on the test2 branch as the (*) shows: To list out all the local branches, you use the following command: git branch Let's look into this in a bit more detail with an example. local_branch_name is the name of the branch you want to delete. It denotes that you want to delete something, as the name suggests.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |