Home > Net >  Does git fetch pick up deleted branches?
Does git fetch pick up deleted branches?

Time:10-19

Use case:

User A's working on branch A forked from master; user B creates branch B forked from master does some work and commits and then deletes branch B. Can user A ever see the work of user B (e.g. git fetch --all). User A has never worked on branch B.

In this case branch B is not showing up for user A.

CodePudding user response:

I suppose that users A and B are on different computers (A and B) and that the master branch is stored on a server.

First

Make a list of repository that have known branch B.

  • The one used by user B on computer B.
  • The one on the server. If user B had pushed branch B on the server.
  • Others ? (user B had pushed branch B on a backup repository).

Second

Make sure that the branch have been deleted from all those repository. If not, A can retrieve branch B from here (ex : the server).

Finally

Take a look at reflog, it provides the recent history of HEAD(local) and can help user B to retrieve branch B after delete. Some git servers also have some identical feature (like github as explained here).

CodePudding user response:

The short answer is "no".

The long answer is Mu: the question as asked is actually meaningless, unless one makes some leaps of interpretation (which I think most people will). The reason is that branches don't matter; you don't (quite) fetch branches. What matters are commits, so the correct question is whether git fetch will fetch these commits (and then the answer is generally "no"

  • Related