I can't exactly remember the events that led me to my current scenario, but it happened something similar to this:
2-dev-inprogress
2-dev-inprogress
to 2-dev-wip
using:
git branch -mv 2-dev-inprogress 2-dev-wip
My problem is that when i am in another branch and want to checkout 2-dev-wip
by using tab-completion (as usual), it only completes 2-dev-
, and gives me two options:
2-dev-inprogress
2-dev-wip
Anybody out there know some specific surgery to remove that 2-dev-inprogress
branch from tab-completion history? Only thing I've tried so far is commenting out source ~/.git-completion.bash
in my .bash_profile and restart iTerm, but no luck. I also snooped around the .git directory, but got scared thinking I would fudge something up beyond repair.
The easiest way to delete local Git branches is to use the “git branch” command with the “-d” option. The “-d” option stands for “–delete” and it can be used whenever the branch you want to clean up is completely merged with your upstream branch. $ git branch -d release Deleted branch feature (was bd6903f).
The commits will still be retained in the repository and it is possible to recover them immediately after the delete, but eventually they will be garbage collected. Thanks for the answer.
Deleting Local Branches First, use the git branch -a command to display all branches (both local and remote). Next, you can delete the local branch, using the git branch -d command, followed by the name of the branch you want to delete.
Deleting a branch LOCALLY Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.
The accepted answer makes sense, but did not work in my situation. If the remote branch no longer exists, then you may additionally need to prune. I used Seth Robertson's suggestion to clean up my system and get rid of many branches all at once: git remote | xargs -n1 git remote prune
. This can happen if another person deleted the remote branch(es) or in my case if you did it from another machine.
Do you still have a remote branch named 2-dev-inprogress
? If so you have to remove this branch or prevent git-completion of remote branches by commenting out the remote checks in /etc/bash_completion.d/git
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With