Reputation: 2901
When would the Fetch URL and Push URL not be the same for a certain remote?
For example, when i run git remote show central
for a remote named central, the output looks like:
* remote central
Fetch URL: [email protected]:/home/aoberoi/Repositories/example.git
Push URL: [email protected]:/home/aoberoi/Repositories/example.git
HEAD branch: master
Remote branch:
master tracked
I just don't see why I would be fetching from and pushing to two different URLs, what type of workflow is this intended for?
Upvotes: 14
Views: 10808
Reputation: 1323203
I am not sure what you mean, since your example includes 2 identical URL, but URLS for push and pull can differ because of:
That being said, commit 697f652 (Git 2.3.1+, Q1/Q2 2015) by Git maintainer Junio C Hamano (gitster
) do mention:
It seems to be a common mistake to try using a single remote (e.g. 'origin') to fetch from one place (i.e.
upstream
) while pushing to another (i.e. your publishing point).That will never work satisfactorily, and it is easy to understand why if you think about what
refs/remotes/origin/*
would mean in such a world. It fundamentally cannot reflect the reality.
If it follows the state of your upstream, it cannot match what you have published, and vice versa.The documentation wasn't clear that "
remote.<nick>.pushURL
" and "remote.<nick>.URL
" are there to name the same repository accessed via different transports, not two separate repositories.
Upvotes: 12
Reputation: 143064
I think you could use it if you wanted a "staging" repo contributors would push to, and then others would push changes from there to the main repo after review and approval. So you'd fetch from the main repo, and push to the staging repo.
Upvotes: 0