gitless icon indicating copy to clipboard operation
gitless copied to clipboard

Remove remote-tracking branch on branch deletion or unset upstream if it is not used anymore

Open chmike opened this issue 8 years ago • 4 comments

I deleted a branch that I just merged in master. That branch had an upstream branch, but the upstream pointer is not removed from the git repository.

The branch was named feature-xxx and the upstream branch origin/feature-xxx. When I delete the branch feature-xxx, the pointer for origin/feature-xxx is still there. I can see it with git branch -r. In fact I also use gitk who displays it too.

How can I remove this origin/feature-xxx pointer ? I don't feel like trying to gl branch -d origin/feature-xxx because I fear it affects the origin repository.

Shouldn't deleting a branch also delete the upstream branch pointer ?

chmike avatar Nov 23 '16 16:11 chmike

Yes, we should. I assume you just want this so as to save space, right?

Don't do gl branch -d origin/feature-xxx, that will delete the branch in the remote repository (in Gitless, origin/feature-xxx refers to the feature-xxx branch that lives in the remote repository origin)

spderosso avatar Nov 23 '16 16:11 spderosso

Yes. I tried it. Thankfully I was asked if I wanted to remove the remote branch.

I could remove the remote pointer with the git command git branch -d -r origin/feature-xxx.

If I understood correctly, this branch/pointer is useless once the local branch is removed. It shows up in gui tools like gitk for instance. The unset-upstream doesn't remove it.

chmike avatar Nov 23 '16 16:11 chmike

Could it also be removed if the branch tracking it is removed and there are not other branch tracking it ? Thanks

chmike avatar Nov 23 '16 17:11 chmike

Yes, we can remove Git's remote-tracking branch pointer if no other branch is using it in that case too

spderosso avatar Nov 23 '16 17:11 spderosso