jondavidjohn jondavidjohn - 10 months ago 51
Git Question

Git - Forking without Github

Is the function of "forking" specific to github? or is there a purely git process for creating "copied" child repositories that can pull updates from the parent? If so, how?

EDIT : I must be confused about what

git clone
does then. It was my understanding that
git clone
is what I do on my machine to get a local copy of the repository to make changes to,
, and
from. We are currently hosting our repos with gitosis. So if I wanted to accompish a 'fork' I would clone the repository on the gitosis server itself (at the origin)? Would that create a new git address?

Answer Source

You probably don't want to actually do this. Branches in git are very nice and lightweight, and there really isn't a reason why you shouldn't just make a branch in the repository that you have right now. The only reason I can think of to do this with a gitosis repository is in order to make access control interesting, if you have a continuous deploy or something which pulls from one gitosis repository and you want to give commit access to the same code but don't want them to be able to write to the one that is deployed. For all other uses, you should just make a branch with git branch and do all your work on the branch. Alternately you might want to clone a github repository and then have a team work on it within your central gitosis architecture.

Given that pre-warning, the easiest way to create a "fork" in the way that you describe, is to make a separate repository on the gitosis server. So set up another repository with the other name - for example if your original repository is gitosis@server:repo1.git you would set up another one at gitosis@server:repo1-fork.git. Add whatever users you want to have access.

Then you would clone the repository: git clone gitosis@server:repo1.git which puts a full copy of the repo into ./repo1. To copy it from your local version to the forked repository, you can do a git push gitosis@server:repo-fork.git --mirror.