Git control remote link

I have a list of github download requests. I can get stretch requests like this:

git fetch origin +refs/pull/*:refs/remotes/origin/pr/* 

I get the output as follows:

 * [new ref] refs/pull/1/head -> origin/pr/1/head * [new ref] refs/pull/1/merge -> origin/pr/1/merge * [new ref] refs/pull/10/head -> origin/pr/10/head * [new ref] refs/pull/10/merge -> origin/pr/10/merge * [new ref] refs/pull/11/head -> origin/pr/11/head * [new ref] refs/pull/11/merge -> origin/pr/11/merge 

Now I want to check out one of these links. Nothing seems to work:

 $ git checkout refs/pull/1/head error: pathspec 'refs/pull/1/head' did not match any file(s) known to git. 

Or:

 git checkout origin/pr/1/head error: pathspec 'origin/pr/1/head' did not match any file(s) known to git. 

How can I check this link?

+4
source share
2 answers

The first command ( git checkout refs/pull/1/head ) does not work, because refs/pull/1/head is the name of the link in the remote repository. You do not have a link to this name in your local repository, because your fetch refspec translated it to refs/remotes/origin/pr/1/head .

The second command ( git checkout origin/pr/1/head ) should work, although it should give you a "disconnected HEAD" warning. Was there a typo that you corrected when sending your question to "Stack Overflow"?

Your fetch refspec told git to translate remote links to local links in the refs/remotes . Links in this directory are specially processed - these are “remote links” designed to indicate the status of the remote repository the last time you did fetch . Usually you do not want to directly check these links - you want to create a local branch configured to “track” or “track” the remote link (which allows you to use special convenient combinations, such as the version parameter @{u} and easier push / pull ).

Try:

 git checkout -b whatever-branch-name-you-want origin/pr/1/head 

The above creates a new local branch named whatever-branch-name-you-want (I recommend calling it pr/1/head ), pointing to the same latch as origin/pr/1/head , setting up whatever-branch-name-you-want to track origin/pr/1/head , and then switch to a new branch.

+5
source

Verify what is available for verification with

 git branch -a 
0
source

All Articles