What's the difference between `git fetch origin` and `git fetch git://127.0.0.1/`











up vote
2
down vote

favorite












I am experimenting with git and have created a repository in ~/A containing only a master branch.



I have then cloned this repository into ~/B (by starting a git daemon in ~/A and running git clone git://127.0.0.1/).



I then created a new test branch in ~/A and tried to get that branch in ~/B. However, git fetch git://127.0.0.1/ only showed



From git://127.0.0.1
* branch HEAD -> FETCH_HEAD


To get the new branch I ended up doing git fetch, which as far as I understand is equivalent to git fetch origin. In any case, both of these give me



From git://127.0.0.1
* [new branch] test -> origin/test


after which I can start working on the test branch in ~/B by doing git checkout test.



How is it possible that git fetch git://127.0.0.1/ and git fetch origin have different results, when git remote -v shows



origin  git://127.0.0.1/ (fetch)
origin git://127.0.0.1/ (push)


The daemon shows the same request for all commands, namely



[20291] Extended attribute "host": 127.0.0.1
[20291] Request upload-pack for '/'









share|improve this question
























  • Your Git URL does not look correct, see here. I think it should be ending in .git.
    – Tim Biegeleisen
    Nov 11 at 7:42










  • @TimBiegeleisen I got that part from gist.github.com/RichardBronosky/… Note that git clone git://127.0.0.1/ does not cause any problem
    – Bananach
    Nov 11 at 8:44










  • @TimBiegeleisen It's not required that the URL ends in .git. That's only a convention.
    – David Z
    Nov 11 at 11:28















up vote
2
down vote

favorite












I am experimenting with git and have created a repository in ~/A containing only a master branch.



I have then cloned this repository into ~/B (by starting a git daemon in ~/A and running git clone git://127.0.0.1/).



I then created a new test branch in ~/A and tried to get that branch in ~/B. However, git fetch git://127.0.0.1/ only showed



From git://127.0.0.1
* branch HEAD -> FETCH_HEAD


To get the new branch I ended up doing git fetch, which as far as I understand is equivalent to git fetch origin. In any case, both of these give me



From git://127.0.0.1
* [new branch] test -> origin/test


after which I can start working on the test branch in ~/B by doing git checkout test.



How is it possible that git fetch git://127.0.0.1/ and git fetch origin have different results, when git remote -v shows



origin  git://127.0.0.1/ (fetch)
origin git://127.0.0.1/ (push)


The daemon shows the same request for all commands, namely



[20291] Extended attribute "host": 127.0.0.1
[20291] Request upload-pack for '/'









share|improve this question
























  • Your Git URL does not look correct, see here. I think it should be ending in .git.
    – Tim Biegeleisen
    Nov 11 at 7:42










  • @TimBiegeleisen I got that part from gist.github.com/RichardBronosky/… Note that git clone git://127.0.0.1/ does not cause any problem
    – Bananach
    Nov 11 at 8:44










  • @TimBiegeleisen It's not required that the URL ends in .git. That's only a convention.
    – David Z
    Nov 11 at 11:28













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I am experimenting with git and have created a repository in ~/A containing only a master branch.



I have then cloned this repository into ~/B (by starting a git daemon in ~/A and running git clone git://127.0.0.1/).



I then created a new test branch in ~/A and tried to get that branch in ~/B. However, git fetch git://127.0.0.1/ only showed



From git://127.0.0.1
* branch HEAD -> FETCH_HEAD


To get the new branch I ended up doing git fetch, which as far as I understand is equivalent to git fetch origin. In any case, both of these give me



From git://127.0.0.1
* [new branch] test -> origin/test


after which I can start working on the test branch in ~/B by doing git checkout test.



How is it possible that git fetch git://127.0.0.1/ and git fetch origin have different results, when git remote -v shows



origin  git://127.0.0.1/ (fetch)
origin git://127.0.0.1/ (push)


The daemon shows the same request for all commands, namely



[20291] Extended attribute "host": 127.0.0.1
[20291] Request upload-pack for '/'









share|improve this question















I am experimenting with git and have created a repository in ~/A containing only a master branch.



I have then cloned this repository into ~/B (by starting a git daemon in ~/A and running git clone git://127.0.0.1/).



I then created a new test branch in ~/A and tried to get that branch in ~/B. However, git fetch git://127.0.0.1/ only showed



From git://127.0.0.1
* branch HEAD -> FETCH_HEAD


To get the new branch I ended up doing git fetch, which as far as I understand is equivalent to git fetch origin. In any case, both of these give me



From git://127.0.0.1
* [new branch] test -> origin/test


after which I can start working on the test branch in ~/B by doing git checkout test.



How is it possible that git fetch git://127.0.0.1/ and git fetch origin have different results, when git remote -v shows



origin  git://127.0.0.1/ (fetch)
origin git://127.0.0.1/ (push)


The daemon shows the same request for all commands, namely



[20291] Extended attribute "host": 127.0.0.1
[20291] Request upload-pack for '/'






git git-remote git-fetch






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 11:23

























asked Nov 11 at 7:33









Bananach

374114




374114












  • Your Git URL does not look correct, see here. I think it should be ending in .git.
    – Tim Biegeleisen
    Nov 11 at 7:42










  • @TimBiegeleisen I got that part from gist.github.com/RichardBronosky/… Note that git clone git://127.0.0.1/ does not cause any problem
    – Bananach
    Nov 11 at 8:44










  • @TimBiegeleisen It's not required that the URL ends in .git. That's only a convention.
    – David Z
    Nov 11 at 11:28


















  • Your Git URL does not look correct, see here. I think it should be ending in .git.
    – Tim Biegeleisen
    Nov 11 at 7:42










  • @TimBiegeleisen I got that part from gist.github.com/RichardBronosky/… Note that git clone git://127.0.0.1/ does not cause any problem
    – Bananach
    Nov 11 at 8:44










  • @TimBiegeleisen It's not required that the URL ends in .git. That's only a convention.
    – David Z
    Nov 11 at 11:28
















Your Git URL does not look correct, see here. I think it should be ending in .git.
– Tim Biegeleisen
Nov 11 at 7:42




Your Git URL does not look correct, see here. I think it should be ending in .git.
– Tim Biegeleisen
Nov 11 at 7:42












@TimBiegeleisen I got that part from gist.github.com/RichardBronosky/… Note that git clone git://127.0.0.1/ does not cause any problem
– Bananach
Nov 11 at 8:44




@TimBiegeleisen I got that part from gist.github.com/RichardBronosky/… Note that git clone git://127.0.0.1/ does not cause any problem
– Bananach
Nov 11 at 8:44












@TimBiegeleisen It's not required that the URL ends in .git. That's only a convention.
– David Z
Nov 11 at 11:28




@TimBiegeleisen It's not required that the URL ends in .git. That's only a convention.
– David Z
Nov 11 at 11:28












1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










When you run git fetch origin you are asking git to look up the configuration for your remote named origin, fetch from the configured URL and write any fetchspec mapping to store the remote’s information in remote tracking branches (eg mapping your refs/remotes/origin/master to the remote’s refs/heads/master).



When you run git fetch <url>, you bypass the remote configuration. git does not try to match the url to a remote and use the remote configuration. (Indeed that would be ambiguous, you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs).



Instead, git fetch <url> will fetch from the specified url directly, and put the remote’s HEAD into your FETCH_HEAD file. Since there is no remote, it does not update remote tracking branches. You can inspect FETCH_HEAD to see what you’ve fetched, however it’s much easier to fetch with a remote instead of a url.






share|improve this answer

















  • 2




    You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
    – Bananach
    Nov 11 at 11:14










  • That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
    – Edward Thomson
    Nov 11 at 12:43











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246722%2fwhats-the-difference-between-git-fetch-origin-and-git-fetch-git-127-0-0-1%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
2
down vote



accepted










When you run git fetch origin you are asking git to look up the configuration for your remote named origin, fetch from the configured URL and write any fetchspec mapping to store the remote’s information in remote tracking branches (eg mapping your refs/remotes/origin/master to the remote’s refs/heads/master).



When you run git fetch <url>, you bypass the remote configuration. git does not try to match the url to a remote and use the remote configuration. (Indeed that would be ambiguous, you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs).



Instead, git fetch <url> will fetch from the specified url directly, and put the remote’s HEAD into your FETCH_HEAD file. Since there is no remote, it does not update remote tracking branches. You can inspect FETCH_HEAD to see what you’ve fetched, however it’s much easier to fetch with a remote instead of a url.






share|improve this answer

















  • 2




    You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
    – Bananach
    Nov 11 at 11:14










  • That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
    – Edward Thomson
    Nov 11 at 12:43















up vote
2
down vote



accepted










When you run git fetch origin you are asking git to look up the configuration for your remote named origin, fetch from the configured URL and write any fetchspec mapping to store the remote’s information in remote tracking branches (eg mapping your refs/remotes/origin/master to the remote’s refs/heads/master).



When you run git fetch <url>, you bypass the remote configuration. git does not try to match the url to a remote and use the remote configuration. (Indeed that would be ambiguous, you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs).



Instead, git fetch <url> will fetch from the specified url directly, and put the remote’s HEAD into your FETCH_HEAD file. Since there is no remote, it does not update remote tracking branches. You can inspect FETCH_HEAD to see what you’ve fetched, however it’s much easier to fetch with a remote instead of a url.






share|improve this answer

















  • 2




    You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
    – Bananach
    Nov 11 at 11:14










  • That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
    – Edward Thomson
    Nov 11 at 12:43













up vote
2
down vote



accepted







up vote
2
down vote



accepted






When you run git fetch origin you are asking git to look up the configuration for your remote named origin, fetch from the configured URL and write any fetchspec mapping to store the remote’s information in remote tracking branches (eg mapping your refs/remotes/origin/master to the remote’s refs/heads/master).



When you run git fetch <url>, you bypass the remote configuration. git does not try to match the url to a remote and use the remote configuration. (Indeed that would be ambiguous, you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs).



Instead, git fetch <url> will fetch from the specified url directly, and put the remote’s HEAD into your FETCH_HEAD file. Since there is no remote, it does not update remote tracking branches. You can inspect FETCH_HEAD to see what you’ve fetched, however it’s much easier to fetch with a remote instead of a url.






share|improve this answer












When you run git fetch origin you are asking git to look up the configuration for your remote named origin, fetch from the configured URL and write any fetchspec mapping to store the remote’s information in remote tracking branches (eg mapping your refs/remotes/origin/master to the remote’s refs/heads/master).



When you run git fetch <url>, you bypass the remote configuration. git does not try to match the url to a remote and use the remote configuration. (Indeed that would be ambiguous, you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs).



Instead, git fetch <url> will fetch from the specified url directly, and put the remote’s HEAD into your FETCH_HEAD file. Since there is no remote, it does not update remote tracking branches. You can inspect FETCH_HEAD to see what you’ve fetched, however it’s much easier to fetch with a remote instead of a url.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 11 at 9:03









Edward Thomson

48.1k9101141




48.1k9101141








  • 2




    You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
    – Bananach
    Nov 11 at 11:14










  • That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
    – Edward Thomson
    Nov 11 at 12:43














  • 2




    You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
    – Bananach
    Nov 11 at 11:14










  • That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
    – Edward Thomson
    Nov 11 at 12:43








2




2




You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
– Bananach
Nov 11 at 11:14




You say "you can have multiple remotes with the same URL, which might be useful for configuring different fetch specs". Where can I investigate these "fetch specs"? I would have guessed git remote -v shows me all there is to know about remotes but as mentioned in the question this command only shows URLs
– Bananach
Nov 11 at 11:14












That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
– Edward Thomson
Nov 11 at 12:43




That's a good question - I don't see an obvious easy command to do it; you can run git config --get-all remote.origin.fetch. (I would have expected a git remote command but I don't see one.)
– Edward Thomson
Nov 11 at 12:43


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246722%2fwhats-the-difference-between-git-fetch-origin-and-git-fetch-git-127-0-0-1%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation