Deleting a Local Branch:
You can not delete a branch if you are already inside it, so if you want to delete a branch named - "test_branch" you have to switch to some other branch first.
$ git checkout master # switch to any other branch
$ git branch -d test_branch # delete the local branch
Sometime, if branch have some uncommitted changes then it will throw error. You can use below command to force the deletion.
$ git branch -d test_branch # delete the local branch
Sometime, if branch have some uncommitted changes then it will throw error. You can use below command to force the deletion.
$ git branch -D test_branch # delete the local branch forcefully
Deleting a Remote Branch:
It is a good practice to sync the remote branch details into local repo first, before deleting any remote branch, which we can do by running below command -
$ git fetch -p
Now, we can delete the remote branch by following below command template -
$ git push remote_name -d branch_name # delete the remote branch
i.e. - Usually, remote_name is 'origin' so the command will be -
$ git push origin -d test_branch
Like the below page to get the update
Facebook Page Facebook Group Twitter Feed Telegram Group
No comments:
Post a Comment