Git delete branch without cloning?
Is there a way to remove a branch from a Git repository without doing cloning or any other local copy?
Basically I'm working on a panel for a release pipeline and don't want to have any working project code on the Dashboards server just to remove the deployed feature branches.
In case it matters, we are using Atlassian Stash, not Github.
I want to do something similar to:
git branch -D ssh://git@repository.com/team/project/feature/deleteme
source to share
Easy, from any git repo
git push u://r/l +:refs/heads/branchname
and if you don't have a suitable one, just do trash anywhere for example. git init deleteme
...
Some repo administrators who had to give push access to untrusted developers have disabled access on a one-by-one basis, so some repositories will reject this command, but it is enabled by default.
source to share
You can use Stash REST API (utils branches) . You will need to send an authenticated (see link for more information) DELETE
-request to the url like:
/rest/branch-utils/1.0/projects/{projectKey}/repos/{repositorySlug}/branches
... with a parameter name
that specifies the branch you want to delete and (optional?) dryRun
that, as the name suggests , does not actually apply the changes, but results in a response as if the changes were attached.
The request can be issued to almost anyone that can be authenticated. curl
can do it for example.
source to share