问题
After reading Joel's last article on Mercurial, I'm giving it a shot on XP as a single-user, single-computer source control system.
One thing I'd like to check, though, is: It'd be easier to just create a repository of all the tiny projects I keep in eg. C:\VB.Net\, but the result is that the changes I make to the different projects therein (C:\VB.Net\ProjectA\, C:\VB.Net\ProjectB\, etc.) will be mixed in a single changelog.
But if I use a single repository for all projects, when I do diff's or go through the change history, will I be able to filter data so that I only see changes pertaining to a given project? Otherwise, is creating repositories in each project directory the only solution?
Thank you.
回答1:
I'd keep one repository for each single project. The overhead is minimal (just one hg init
for each source code directory, or one right-click in Explorer), and you won't get confused. After all, why should a change to one program affect the version history of a completely unrelated one?
Of course, you can see the history of each file in the Repository Explorer, but I think it goes against the very concept of version control to mix unrelated stuff into one repository.
回答2:
The right granularity for a DVCS (i.e. a repo where all the history can be cloned) is the project.
If you have several projects which have different development lifecycle (i.e. a change in one does not always affect the other), they should be in their own repo.
回答3:
In case somebody uses bitbucket, they allow a only one private repository, so you can put all your projects in there if you want them to be private. I would like to hear comments about this scenario.
回答4:
If you do go with one repository, and only have shallow projects:
cd C:\VB.Net\ProjectA\
hg log *.*
Otherwise, may have to specify specific file extensions to avoid too much recursion:
cd C:\VB.Net\ProjectA\
hg log **/*.cpp
It can be a little slow though... And tags/branches might get confusing if the projects really are separate.
Note: I hardly think "Hello world!" deserves its own repository just because it may be "stand alone".
来源:https://stackoverflow.com/questions/2475520/one-repository-multiple-projects-without-getting-mixed-up