Use Case: I have some repo on GitHub, someone forked it and added new feature and initiated pull request. I can't automatically merge it because there are some minor problems I would like to fix first.
It's one-time activity I'll never need this remote repository, so I don't want to create local remote
branch.
Basically I would like to do:
How to do that?
git checkout git://github.com/xxx/xxx.git
doesn't works at all (fail with error)
git fetch git://github.com/xxx/xxx.git
works but doesn't update anything
You want to use FETCH_HEAD
.
whenever you run git fetch ...
a magic reference called FETCH_HEAD
is created.
Try for example:
git fetch git://github.com/xxx/xxx.git branch_name && git merge FETCH_HEAD
For any Git server:
git fetch git://host.com/path/to/repo.git remote-branch-name:local-branch-name
git checkout local-branch-name
Another neat method (at least on/from Github) is fetching like this:
git fetch repo pull/7324/head:pr-7324
Where:
repo
points to the remote repo, e.g. git://github.com/xxx/xxx.git
.
pull/7324/head
is the remote pull request.
pr-7324
is the local pull-request branch.
Then you can use the local PR branch to do whatever you want with it.
Source: adapted from this discussion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With