Current recommendation is to add a new remote fetching all PRs, but this is resource-intensive.
Document a better way to fetch a single PR, and to update a PR which has been force-pushed.
Follows up on a comment from 32774
Current recommendation is to add a new remote fetching all PRs, but this is resource-intensive.
Document a better way to fetch a single PR, and to update a PR which has been force-pushed.
Follows up on a comment from 32774
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32783.
See the guideline for information on the review process.
Type | Reviewers |
---|---|
ACK | janb84, pablomartin4btc, theStack, achow101 |
Concept ACK | BrandonOdiwuor |
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.
192+```bash
193+# Fetch
194+git fetch upstream pull/<number>/head:pr-<number> && git switch pr-<number>
195+
196+# Update (even after force push)
197+git fetch --update-head-ok -f upstream pull<number>/head:pr-<number>
0git fetch upstream pull/<number>/head
Could either remove the branch creation, or mention that it optional?
update
command.
198+```
199+
200+...from the command line, substituting `<number>` with the PR number you want to fetch/update.
201+
202+> [!NOTE]
203+> We assume here that the `github.com/bitcoin/bitcoin.git` remote is called "upstream".
0> The repository "upstream" must be the one that the pull requests was opened against.
could clarify for the gui repos as well and keep general?
193+# Individual fetch
194+git fetch upstream pull/<number>/head
195+
196+# Fetch with automatic branch creation and switch
197+git fetch upstream pull/<number>/head:pr-<number> && git switch pr-<number>
198+```
0git fetch origin pull/<number>/head
1
2# Fetch with automatic branch creation and switch
3git fetch origin pull/<number>/head:pr-<number> && git switch pr-<number>
NIT, lets align the remote names.
Line 171 uses origin
, lines 181 sets it to upstream-pull
here we are using upstream
. I think that if you just pull the repo the remote will default to origin
?
Line 171 uses
origin
, lines 181 sets it toupstream-pull
here we are usingupstream
. I think that if you just pull the repo the remote will default toorigin
?
you can’t use origin
, as this is not the one the pull was opened against. upstream-pull is a different remote as well. It really needs to be a dedicated one for each repo
Line 171 uses
origin
, lines 181 sets it toupstream-pull
here we are usingupstream
. I think that if you just pull the repo the remote will default toorigin
?you can’t use
origin
, as this is not the one the pull was opened against. upstream-pull is a different remote as well. It really needs to be a dedicated one for each repo
when i use the command as specified it fails:
0bitcoin]$ git fetch upstream pull/32783/head
1fatal: 'upstream' does not appear to be a git repository
2fatal: Could not read from remote repository.
when I use origin (this is my remote) this works
0bitcoin]$ git remote -v
1origin https://github.com/bitcoin/bitcoin.git (fetch)
2origin https://github.com/bitcoin/bitcoin.git (push)
Did I miss a obvious step ?
@janb84 most developers here will have two remotes configured:
origin
: their personal fork of the repo they make changes in
upstream
: the upstream repo you make PRs against
These are the most common names for them, but you can set them to be whatever you like.
If you just do git clone https://github.com/bitcoin/bitcoin
it will set the remote to origin
automagically (unless otherwise directed).
I’d prefer to avoid spelling this out in this document though. I think this is not a “git from scratch” guide, but more advanced tips for better productivity.
when I use origin (this is my remote) this works
I’d expect that normally origin
refers to your_user_name/bitcoin-core
, not to bitcoin/bitcoin
.
This would give:
0$ git fetch origin pull/32783/head
1fatal: couldn't find remote ref pull/32783/head
Maybe, if all of this is more confusing than helpful, it could make sense to just omit it from the docs (and close this pull :sweat_smile: )
Fetching by commit id should work with any remote already, with the only downside of having to do two more clicks to copy the commit id.
I’d prefer to avoid spelling this out in this document though. I think this is not a “git from scratch” guide, but more advanced tips for better productivity.
Ok with that in mind ignore my NIT.
when I use origin (this is my remote) this works
I’d expect that normally
origin
refers toyour_user_name/bitcoin-core
, not tobitcoin/bitcoin
.This would give:
0$ git fetch origin pull/32783/head 1fatal: couldn't find remote ref pull/32783/head
Maybe, if all of this is more confusing than helpful, it could make sense to just omit it from the docs (and close this pull 😅 )
Fetching by commit id should work with any remote already, with the only downside of having to do two more clicks to copy the commit id.
No I think it’s quite clear for advanced users, not that hard to figure out. I wasn’t reading this document with advanced users in mind. My mistake.
you can just specify the specific source
ie for this PR
git fetch https://github.com/bitcoin/bitcoin pull/32783/head
or
git fetch https://github.com/bitcoin/bitcoin pull/32783/head:pr-32783 && git switch pr-32783
ACK 83ccae194d0de3e64af54174898f030594be3a4f
In previous section (“Reference PRs easily with refspec
s”), also touched recently in #32774, it could be mentioned that the user could use git remove add
… instead of adding the remote manually into the git config file.
199+
200+...from the command line, substituting `<number>` with the PR number you want to fetch/update.
201+
202+> [!NOTE]
203+> The remote named "upstream" here must be the one that the pull request was opened against.
204+> e.g. github.com/bitcoin/bitcoin.git or for the GUI github.com/bitcoin-core/gui
git remote -v
(and maybe as you said, git clone
adds the origin automatically - keeping in mind what you also said that this is not a git guide).
205+
206+Make these easier to use by adding aliases to your git config:
207+
208+```
209+[alias]
210+ # Fetch a and checkout in a new branch a single pr with `git pr 12345`
0 # Fetch and checkout a single pr in a new branch with `git pr 12345`
(not a native english speaker, so maybe my word order gut-feeling is tricking me here and it’s also fine as-is… the first “a” seems superflous though)
Current recommendation is to add a new remote fetching all PRs, but this
is resource-intensive.
Document a better way to fetch a single PR, and to update a PR which has
been force-pushed.
re ACK 45b1d39757668939b03b27401c324a938ef0cd8d
Changes sinds last ACK:
192+```bash
193+# Individual fetch
194+git fetch upstream pull/<number>/head
195+
196+# Fetch with automatic branch creation and switch
197+git fetch upstream pull/<number>/head:pr-<number> && git switch pr-<number>
git switch
instead of git checkout
?