How to tell Git to alert me of possibly deleted remote branches

So, imagine that I have a local repository that I cloned from some source. During my internal clone, the source had four branches: featureA, featureB, featureC and the master . If I make changes to the beginning that remove the featureA branch, I expect to see something about this that will be removed in the next release:

$ git pull origin

However, what happens, I don’t see anything and when I try to pull this particular branch using

$ git attribute pull originA

I get the following error:

fatal: Could not find remote refA function

fatal: the remote end hung up unexpectedly

This makes perfect sense, since the branch has actually been removed from the remote, so yes, ref no longer exists, but I wonder why I did not receive a notification about this fact. My .git / config for the remote device looks like this:

[remote "origin"]
fetch = + refs / heads /: refs / remotes / origin /
url = cjames@svn.perecep.com: /data/git/perecep.git

I wrote a small shell script that uses git ls-remote along with exiting git branch -r to detect remote refs whose branches no longer exist on the server and tell me if I want to delete them, but I wonder if I do Am I something inherently wrong here?

+7
git
source share
2 answers

Well, there is no need for a special script. I think I missed this team

$ git remote black source

On the man page:

   prune
            Deletes all stale tracking branches under.  These stale branches 
            have already been removed from the remote repository referenced by 
            , but are still locally available in "remotes /".

            With --dry-run option, report what branches will be pruned, but do 
            no (sic) actually prune them.
+3
source share

I do not think that you are doing something wrong. Your local branch does not depend on the remote branch for existence, and this is an ideal state of affairs for the remote branch, which will be deleted while your local branch (with the same name and supposedly the same story) continues to exist. This is the "centralized" approach that you describe, at least that will be considered unorthodox in Git.

Edit: you might be interested in the --track and --no-track options for git-branch and branch.autosetupmerge config.

+2
source share

All Articles