2

My issue primarily relies around using Git. I am currently using code from Elastalert's official GitHub repo, but they have yet to add support for Elasticsearch version 7 that was just released this week. I see that another user has added his code to fix the issue and there is a pull request in GitHub here. Is there a way that I can clone this user's code from the pull request instead of the official code from the Elastalert repository? In this case, the official repository doesn't work on our version of Elasticsearch and I don't want to wait for Yelp to approve the pull request. I am new to using Git and GitHub, so a basic explanation would be great.

phd
  • 82,685
  • 13
  • 120
  • 165

1 Answers1

4

A pull request is a branch. Github names this kind of branches in the format of refs/pull/${number}/head. The number of your interested pull request is 2194, so its name is refs/pull/2194/head. This kind of branches cannot be used as the value of the option -b in git clone, but it can be used in 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

And then you can make new commits on bar.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53