Hg-git: delete remote branch?

Is it possible to delete a remote branch using hg-git ?

I can remove the tag locally ( hg bm -d old-branch ), but it's not clear how to tell the git server to do the same.

+8
git mercurial hg-git
source share
2 answers

This was the one that was discussed on the September 13, 2012 Hg-Git mailing list . The conclusion was that deleting a remote Git branch is not something that Hg-Git supports, and a workaround is to use a separate Git client to delete the remote branch.

I worked on improving the integration of Hg-Git with bookmarks, so it is possible that this feature may be present in a future version of Hg-Git.

Related discussion: https://groups.google.com/d/topic/hg-git/Zj_-JkYsFaA/discussion

+4
source share

Here is an alias for hgrc

If you are on a Posix system, add this alias to your hgrc file:

 # Example invocation: # hg git-delete-remote default/bad-branch gitremotedelete = ! \ remote=`echo $HG_ARGS | sed 's_/.*__' | sed 's_.* __'`; branch=`echo $HG_ARGS | sed 's_.*/__'`; remote_url=$($HG paths $remote | sed 's_^git+ssh://__'); git_dir=$($HG root)/.hg/git; # Delete the remote branch git --git-dir=$git_dir push $remote_url :$branch; # Delete local ref to remote branch git --git-dir=$git_dir branch -rd $remote/$branch; # Delete local branch git --git-dir=$git_dir branch -D $branch echo "Don't forget to run "'`'"hg bookmark -d $branch"'`' 

And call it like this if you want to remotely delete "default / bad-branch":

 # hg gitremotedelete <name of remote>/<branch to delete> hg gitremotedelete default/bad-branch 

Manual execution

If you want to know what does the above: here is how we will do the same as the interactive session. Hope this can be translated to Windows.

We want to remove the Git branch on some remote computer. Find out the URL of the remote default ; if you need some other remote, change as necessary.

 hg paths default # git+ssh://git@example.com:some_user/some_repo.git 

What is a repo root?

 hg root # /home/You/current_repo 

Go to the Git directory under the repo root

 cd /home/You/current_repo/.hg/git 

Speak the magic words that Git gets to remove the remote branch by passing the remote repo url in the style that Git expects

 git push git@example.com:some_user/some_repo.git :branch-to-delete 

Also remove the remote tracking branch because Git does not automatically delete it. Hg-Git generates remote anchor tags on the fly from remote tracking links, so removing a remote tracking branch in Git is necessary and sufficient to no longer see the tag in Mercurial.

 git branch -rd default/branch-to-delete 

Finally, remove the local Git branch (local link):

 git branch -d $branch 
+1
source share

All Articles