Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I would like to clone a repository from GitHub. The problem is I don't want the main branch; I want the version in this unapproved pull request.

Is it possible for me to clone the pull request version instead of the main repository?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
530 views
Welcome To Ask or Share your Answers For Others

1 Answer

The easiest way to do that is like this:

git fetch origin pull/2/head
git checkout -b pullrequest FETCH_HEAD

You will now be on a new branch that is on the state of the pull request.

You might want to set up an alias by running

git config --global alias.pr '!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'

Now you can checkout any PR by running git pr <pr_number>, or git pr <pr_number> <remote> if your github remote is not named origin.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...