Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git delete branch without cloning?

Is there a way to delete a branch from a Git repository without doing a clone or any other sort of local copy?

Basically I'm working on a dashboard for a release pipeline and don't want to have to have any of the working project's code on the dashboards server just to delete deployed feature branches.

In case it matters, we use Atlassian Stash and not Github.

I'm looking to do something similar to:

git branch -D ssh://[email protected]/team/project/feature/deleteme
like image 908
jdarling Avatar asked Aug 06 '15 21:08

jdarling


1 Answers

Easy, from any git repo

git push u://r/l +:refs/heads/branchname

and if you don't happen to have one handy, just make a trash one anywhere with e.g. git init deleteme.

Some repo administrators who've had to give push access to unreliable developers have shut off delete-by-push access, so some repos will reject that command, but it's enabled by default.

like image 99
jthill Avatar answered Oct 31 '22 12:10

jthill