Monday, September 27, 2010

git: prune to remove old remote tracking branches

http://stay-calm.blogspot.com/2009/02/git-prune-to-remove-old-remote-tracking.html



Wednesday, February 4, 2009

git: prune to remove old remote tracking branches

I was trying to delete "somebranch" from a git repository today but got this error message, which baffled me for a bit:

$ git push origin :somebranch
error: unable to push to unqualified destination: somebranch
The destination refspec neither matches an existing ref on the remote nor
begins with refs/, and we are unable to guess a prefix based on the source ref.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git@my_server:my_repo.git'


Doing a 'git branch -a' showed a "origin/somebranch" remote branch. Why can't I delete it? Then I realized that the branch might have been deleted on the remote repository and I haven't updated my remote tracking branches yet. Doing a "git pull" won't remove remote tracking branches for branches that have been deleted. To do that for a remote named "origin", you'll need to use this command:

$ git remote prune origin

1 comment:

  1. Also, if you run git remote show origin, it will show you something like this

    wip tracked
    qa2 tracked
    refs/remotes/origin/properties stale (use 'git remote prune' to remove)
    refs/remotes/origin/auth stale (use 'git remote prune' to remove)
    refs/remotes/origin/1e stale (use 'git remote prune' to remove)
    demo tracked

    ReplyDelete

cancel script completely on ctrl-c

I found this question interesting: basically how to cancel completely a script and all child processes : You do this by creating a subro...