Reputation: 25
I have been working on a private github repository and now I reached a point where I want to make my code public. However, I have some files that I can't make public. So I want configure my future pushes to stay like usual for the private repository and ignore the files in question for the public repository.
Is there a way to configure a single push to do the thing without the need to modify the ignore file and push separately every time? I started trying with aliases with multiple commands but my solution is not clean.
Upvotes: 0
Views: 214
Reputation: 3549
In a word, "no". But to add more details...
A commit in git is a snapshot of all the files in the branch. That same commit can never refer to fewer than all the files. So it is impossible in git to push the same commit to two different repositories, but having different content sent to each.
One thing you could do is to have two separate branches, one with the restricted files and one identical except without them, and you push the one branch to one repo and the other branch to the other. You would keep the two branches in sync with regular merging.
Upvotes: 2