On Tue, 25 Mar 2014 13:33:07 -0700 (PDT)
Fredrik Linder <fredrikelin...@gmail.com> wrote:

> *The another-branch is actually deleted from origin*
> *origin/master*> git branch | grep 'another-branch' | wc -l
> 0
> *Fetching the updated info from origin*
> *clone1/abranch*> git fetch
> *clone1/abranch*> git fetch --all
> *clone1/abranch*> git push -f
> *My clone1 still thinks origin has the deleted branch*
> *clone1/abranch*> git branch -r | grep 'origin/another-branch'
>  origin/another-branch
> Neither git fetch, git fetch --all, git push -f nor git gc on either
> repo fixes this.
> Is this a bug or is there some other command to update clone1?

Supposedly you need to run

    git remote prune origin

in your clone1 repo.

Of course, this is not a bug, you just have somewhat wrong mindset
possibly originated in centralised VC systems.  The idea is that any
repository (or, to be more down-to-earth, any your local repository)
is sacred and no history it contains is to be deleted on occasion;
only when you *explicitly* ask for this.

The reason is that after you have added another repository as a remote
and fetched branches for it (note that doing this automatically for
the remote named "origin" when you clone is just a convenience)
only you decide when you no longer need those "bookmarks" to that
repository's branches -- not whoever is able to push to that repository.
To better understand why this is needed consider that your local
repository might have literally dozens of remote repositories known to
it, and they are all managed by different people.  Suppose you added a
remote named "hax0r" to inspect a pull request from that coder, and
a remote branch hax0r/feature-foo got created in your repo; in the
meantime the used deleted that branch from his repo, but you're still
working with it -- should the next fetch from that repo pull the rug
under your feet?  Supposedly not.  But if you feel like it's okay to
remove that repo's stale branches you have a command to do that.

In the general case your normal local repository is not a dumb mirror of
the repo you cloned it from, -- it's a self-conscious repository with
its own bill of rights.  If you *do* want a dumb mirror, use a bare repo
and clone it with --mirror command-line option or use other means to
achieve the same effect.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to