How does the branches get updated in a Forked repo?

42 views
Skip to first unread message

Manisha Gayathri

unread,
Mar 12, 2014, 8:50:26 AM3/12/14
to git...@googlegroups.com
Hi all, 

This is my scenario:
  • create repo1
  • create branch 1.0.0 for it. now repo1 has master and 1.0.0
  • add user1 to repo1. At user addition, I invoke the fork repo method programatically. When adding user1 to repo1, a fork of repo1 is automatically getting created for him. (~r/user1/repo1.git). This forked repo has both master and 1.0.0
  • create a new version for repo1 as 2.0.0. In this new version creation, I again call the fork repo method.
  • the new branch gets added to the parent repo. But the forked repo does not get updated with the new branch. 
When I checked in the directory structure of the forked repo it is as below:
heads
│   ├── 1.0.0
│   └── master
├── remotes
│   └── origin
│       ├── 1.0.0
│       ├── 2.0.0
│       └── master
└── tags

But in the parent repo, both heads and remotes has the newly added version 2.0.0.
Is this the expected behavior? Why does the fork repo behave in 2 different ways when it initially creates the fork and when it gets updated?

Thanks
Manisha

James Moger

unread,
Mar 12, 2014, 9:42:48 AM3/12/14
to git...@googlegroups.com
This is the expected behavior - but you are also doing something
unexpected because you have access to internal functions: forking
twice. The UI doesn't permit that so you are in uncharted waters.

A fork is a copy of the canonical repo at the time of fork execution.
The fork is not automatically kept in-sync with the canonical repo.
This could be implemented, but there are scenarios to consider like
prohibiting users from pushing to synchronized/inherited branches in
their own forks. And of course what if the canonical repo gets a new
branch, "james", and my fork already has a branch "james". What
happens then... do we clobber my fork's branch because it exists
upstream? There are important details in automatic origin
synchronization which is why I haven't implemented it (yet). This was
all discussed as part of the mirroring discussion [1].

-J

[1]: https://code.google.com/p/gitblit/issues/detail?id=5
Reply all
Reply to author
Forward
0 new messages