Below are some steps to clean branches from the git repository to remove the clutter.
Delete a Local branch
To delete the local branch in Git using the command, we can use one of the followings:
As you can see above, we have 2 different arguments, one with small case d and one with capital case D.
The -d option stands for –delete, which would delete the local branch. The -D option stands for –delete –force, which deletes the branch even if there are uncommitted changes.
Delete a remote branch
To delete a remote branch, we can use the following command:
Above command can also be used if we want to delete git tags.
Delete a Local branch
To delete the local branch in Git using the command, we can use one of the followings:
# git branch -d branch_name
# git branch -D branch_name |
The -d option stands for –delete, which would delete the local branch. The -D option stands for –delete –force, which deletes the branch even if there are uncommitted changes.
Delete a remote branch
To delete a remote branch, we can use the following command:
# git push {remote_name} –delete {branch_name}
|
Above command can also be used if we want to delete git tags.