Reputation:
I would like to do version control on the whole project locally but only push certain files (e.g. tests) to Github. Is there a way to do that? Thanks!
Upvotes: 1
Views: 878
Reputation: 13404
Git works generally by cloning copies of the repository between locations -- for example, between your machine and github. The copy of a repository you have on your machine is basically identical to the repository on github (as well as identical to the copies everyone else might have).
So if one person makes a commit, that commit gets transferred around with all other copies of the repository.
The primary exceptions to this are git branches. (This is a bit of a simplified view, but it works for this discussion.) Branches within the repository are only pushed between repositories if someone specifically takes action to push them.
So if you wanted to push only certain files to and from github, the best way I can see to accomplish this is to create a branch that contains only the files you want to push to github, and then only push that branch. Just don't push the other branches.
You could still merge those files into your development branches -- as well as merge files from your other branches to the branch you pushed.
So I believe this would accomplish what you want.
All this being said, I'd really highly recommend you use git as it was intended and push full copies of all the code around, rather than just push certain files.
Upvotes: 6
Reputation: 1575
I'd agree with Kevin and suggest just pushing the entire repository to GitHub.
However, if there are just some very odd circumstances around your necessity to only have your unit tests housed in GitHub, you could set that up as a separate repository and use is a submodule
in your main repository.
Upvotes: 0