如何使用他人的代码';GitHub上的pull请求是什么?

如何使用他人的代码';GitHub上的pull请求是什么?,git,github,Git,Github,我的问题主要在于使用Git。我目前正在使用Elastalert官方GitHub repo的代码,但他们尚未添加对本周刚刚发布的Elasticsearch版本7的支持。我看到另一个用户已经添加了他的代码来修复这个问题。有没有办法从pull请求中克隆此用户的代码,而不是从Elastalert存储库中克隆正式代码?在这种情况下,官方存储库无法处理我们版本的Elasticsearch,我不想等待Yelp批准拉取请求。我对使用Git和GitHub还不熟悉,所以最好有一个基本的解释 拉请求是一个分支。Git

我的问题主要在于使用Git。我目前正在使用Elastalert官方GitHub repo的代码,但他们尚未添加对本周刚刚发布的Elasticsearch版本7的支持。我看到另一个用户已经添加了他的代码来修复这个问题。有没有办法从pull请求中克隆此用户的代码,而不是从Elastalert存储库中克隆正式代码?在这种情况下,官方存储库无法处理我们版本的Elasticsearch,我不想等待Yelp批准拉取请求。我对使用Git和GitHub还不熟悉,所以最好有一个基本的解释

拉请求是一个分支。Github以
refs/pull/${number}/head
的格式命名此类分支。您感兴趣的拉动请求的编号为
2194
,因此其名称为
refs/pull/2194/head
。这种分支不能用作
git clone
中选项
-b
的值,但可以在
git fetch
中使用

# initialize a local repository "foo". If "foo" already exists, "git init foo" is harmless.
git init foo
cd foo

# create a remote "origin". It is optional. If "origin" is occupied, use another name.
git remote add origin https://github.com/Yelp/elastalert.git

# fetch the pull request
git fetch origin refs/pull/2194/head

# if you didn't create the remote "origin"
git fetch https://github.com/Yelp/elastalert.git refs/pull/2194/head

# create a local branch "bar" from this pull request
git checkout -b bar FETCH_HEAD

# if you don't want to keep the history of the pull request
git checkout --orphan bar FETCH_HEAD
git commit
然后您可以在
上进行新的提交