简体   繁体   中英

Pull a remote branch from Github

I'm using a Github repo master branch.

A fix exists in another branch which for some reason it hasn't been pushed to master:

https://github.com/ftexchange/ftx/pull/13

I'd like to obtain this fix branch (arf-labs-ou:openssl-1.1) in my local repo.

I've tried git branch -a and git branch -r to find arf-labs-ou:openssl-1.1 but neither show it.

How do I checkout/pull/obtain this branch?

The PR / fix is not yet merged, apparently because it has some problems, but you can still fetch the commit in question from GitHub in various ways. Having done so, the syntax for extracting that particular version of the entire file is not:

git checkout arf-labs-ou:openssl-1.1

(as seen in Chetan's comment ), but rather:

git checkout <hash> -- <path>

or:

git restore --source <hash> -- <path>

The commit hash ID containing the update is 60bf8afd64bbdcad0f011153cff27a6faefe86a5 (you can find this by clicking around on GitHub); there are multiple files affected.

If you wish, you can attach a name—branch or tag name—to the commit, eg:

git branch pr13 60bf8afd64bbdcad0f011153cff27a6faefe86a5

You must first fetch their commit, of course; it's available under the name refs/pull/13/head in the repository in which the pull request was made, ie, https://github.com/ftexchange/ftx . You can fetch this commit and give it a branch name all at once:

git fetch https://github.com/ftexchange/ftx refs/pull/13/head:refs/heads/pr13

and now you can git show pr13 to view their commit locally, rather than looking at it on GitHub.

Note that arf-labs-ou:openssl-1.1 is a GitHub-specific name pattern by which GitHub can look up the various repositories and other names found exclusively on GitHub. This string is not useful elsewhere.

Step 1 git checkout . - To clear your local of any uncommitted changes

Step 2 git fetch - Get all branches from remote

Step 3 git checkout arf-labs-ou:openssl-1.1 - Checkout the specific branch you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM