I have the following situation:
I am developing something with some other people on our own (private) server. This is useful to keep the files backed up and available. However, I would also like to host them on github.
Is there a way I can push and pull from my own server, but push (and only push) to github? I would like to disable fetching from github entirely because it doesn't make much sense. Essentially, we would like to use github as a way to publish our application so others can clone it, but still work entirely on our own infrastructure.
I added the remote with git remote add github <url>
and added a push URL for it using git remote set-url --add --push github <url>
.
Now I would need to remove the fetch URL but when I do git remote set-url github --delete <url>
, it says fatal: Will not delete all non-push URLs
.
This is obviously intended behaviour, but I would still like to work around it (or find a good solution to my problem). Can I just delete the fetch URL in my config or does that break anything in the long run? Is there an entirely different solution to my problem?
I've read through Git - Pushing code to two remotes, but the solution presented there adds a second push URL, instead of a new remote. As far as I understand, this is not exactly what I would want, as the manual for git remote
says:
Note that the push URL and the fetch URL, even though they can be set differently, must still refer to the same place. What you pushed to the push URL should be what you would see if you immediately fetched from the fetch URL. If you are trying to fetch from one place (e.g. your upstream) and push to another (e.g. your publishing repository), use two separate remotes.
...so I should rather use two repos, right? Or am I understanding this wrong?