schmunk, on 06 June 2011 - 03:28 PM, said:
I am fairly new to Git and haven't tested the sub-repo feature yet, but that's definitely on my list.
But what's the difference between a fork and a branch in Git? I thought everything is a branch ... or a fork - isn't it the same?
Would be glad, if you could set up an example Yii application with sub-repos.
Branches are local to the repo. I don't know about Git specifically, but in Mercurial, repo branches aren't as fun/easy as a fork is, and I know in Mercurial that users are heavily encouraged to use forks as everything seems to run more smoothly than the branching process. I've tried branches before and didn't enjoy the workflow. After that initial attempt at branching (and subsequently finding that forking is more common), I personally have yet to find a need for a "branch".
Forks are a way for anyone (yourself or any "follower") to create a new repo based on whatever is being forked from. You can (manually) pull in changes from the parent repo whenever you desire, which includes committer & history information (after a pull, you would merge the changes into your fork, and then commit/push the merge).
Within Github (or Bitbucket, if using mercurial), you can then see the heritage of a repository, to see what forks have occurred (full parent/child genealogy).
In my own projects, I use a structure like so:
"Yii Base" (mercurial mirror of Yii SVN repo's /framework/ directory contents)
"Yii Application" (default Yii-generated app with some small customizations, so that I don't have to generate every time. Also contains "Yii Base" as sub-repo in /framework/ dir)
-> "Some Project" (I create a new fork of "Yii Application" for whatever project I happen to be working on)
I use forks and sub-repos to keep changes a bit more segregated, so I can more easily maintain code bases separately. If I create an extension (such as my new Riiak ext), it gets it's own repository, which I have now pulled into "Yii Application" as a /protected/extensions/riiak/ sub-repo. Then all of my projects (which are forked from "Yii Application" can just pull in the latest changes from their parent repo to have the new Riiak sub-repo show up.
Hopefully that post is coherent, I've had a long day.
If you have any questions or don't quite understand what I've said above, just msg me, I'll show you exactly what I'm talking about.
Cheers