Delete remote branch in GIT repo hosted in SAP Cloud Platform

Victor Ho
SAPUI5 best pratices
2 min readOct 23, 2018

Hi,

This topic may be rarely encountered by you, but I just post here just in case you got the same issue. This topic has taken from me lots of time to figure out the solution, so I posted here just to share with anyone who may struggle with it.

Problem

You have 3 remote branches hosted in GIT repository of SAP Cloud platform:

  • origin/master
  • origin/bugfix
  • origin/dev

So development landscape requires you to develop new feature (on branch origin/dev) as the same time fixing bugs (origin/bugfix).

On a bad day, you got an urgent bug, while you’ve already pushed the code to master with the code for a new feature. The manager asked you to roll back the new feature code (since it’s not compliant with the bug fix for old version), then apply the bug fix first. You did that only to found out that now the remote branch origin/dev is having a different history with other branches, making it not consistent.

How to fix the resolve this inconsistency but still keep the history of the repo clean (not using mering)?

Many of you may think of hard-reset the branch. Correct! Unfortunately, you can’t do it using Web IDE, at least the point I write this article. To make it worse, SAP GIT service provides no UI tool to maintain the GIT repo.

Solution

Using GIT BASH and command line to delete the remote branch:

$ git push --delete <remote_name> <branch_name>

Or:

$ git push <remote_name> --delete <branch_to_delete>

For example, you want to delete a test branch from remote origin:

$ git push origin -d test

Requirement:

When you enter the above command, the Terminal will ask for user & password. Your user needs to have the authorization for maintaining the remote GIT repository in order to execute those function successfully. If your user doesn’t have authorization, then contact the administrator of your company’s SAP Cloud platform.

Note about Proxy

Keep in mind that if you’re inside a corporate network. You may not access to remote server easily. You need to set up the proxy using below command:

blocked by your company network. If so, use below command to setup the proxy:

$ git config — global http.proxy http://<username>:<password>@<proxy-server-url>:<port>

You may not provide a password. you can input it later when you initiate an action (e.g cloning) that require access to public domain.

Hope that help!

—V —

--

--

Victor Ho
SAPUI5 best pratices

Utilize technology to help people have better life.