问题
I have a repo with two sub-repos set up like this:
project/
|-- folder1
|-- folder2
|-- www [subrepo]
|-- dev [subrepo]
On Machine A, I have checked out project, www, and dev, and modified .hgsub as such. I have to commit this in order for the www and dev subrepositories to be recognised by hg (commit -S, etc).
However Machine B only uses the www functionality of the project, so it looks like this:
project/
|-- folder1
|-- folder2
|-- www [subrepo]
Again, the .hgsub in Machine B only has an entry for www, and I have to commit this for hg to recognise it as a subrepo.
What I'd like to do is do push and pull to my central repo but NOT push/pull the .hgsub. Otherwise, if I commit and push .hgsub from Machine A say, and then pull from Machine B, I automatically get the dev subrepo as well as the www subrepo that I don't want.
So I modify .hgsub again on Machine B to only have www and commit it for it to take effect. I do some work in the www subrepo on Machine B and want to push back out to the central repo, but it will also push out the change to .hgsub. Now when I pull on Machine A, my 'dev' subrepo is gone and I have to add it back to .hgsub again, and I go back and forth like this until I pull my hair out in frustration.
Is there any way to get around this? .hgsub must be locally committed on each machine in order for the subrepos to work, but I don't want them to be pushed or pulled. Is there a .hgignore for push/pull?
cheers.
回答1:
A push/pull doesn't operate on files, it operates on changesets.
As such, there is no way to push/pull a partial changeset, either you push/pull it, or you don't.
If you don't want the repository to always contain that file/sub-repository, you shouldn't organize your projects like that. Instead you might want to look into setting up a secondary project with just the sub-repositories you need for that other site.
In other words, you might look into having 2 projects, one with all the sub-repos, the other with just a few.
来源:https://stackoverflow.com/questions/7198934/mercurial-can-i-ignore-a-file-for-push-pull-but-still-commit-hgsub