Some Git Handy Dandys (Ongoing)

Deleting a Branch on the Origin Server Without GUI Interface

Update your local with origin git information

$ git fetch

See what branches are stored on the origin git server

$ git branch -a // shows local and remote branches
$ git branch -r // shows remote branches

Delete a branch

The command we’re headed for:

$ git push origin :<branch-name>

Let’s start with this command:

$ git push origin <my-branch-name>

What’s going on is your local git server is seeing that you have a branch and pushing it to a branch of the same name on the origin git server.

In essence, it’s a shortcut for:

$ git push origin <my-local-branch-name>:<my-origin-branch-name>

This comes in handy when you’re wanting to do some work on different branches on your local and push it to a branch that already has some (compatible) history on it but just so happens to have a different name.

Back to the point, what you’re doing when you execute our delete command is you are pushing a non-branch, if we can call it that, to an existing branch on the origin git server, which the server interprets as a delete.

$ git push origin :<my-origin-branch-name>

Presto change-o, you’ve deleted a branch.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.