Merge bitcoin/bitcoin#32774: doc: Explain how to fetch commits directly

fa94fd53c9 doc: Explain how to fetch commits directly (MarcoFalke)

Pull request description:

  This is often needed, and works better than the existing refspec documentation, because even commits that have been force-pushed away can be fetched (as long as they are not garbage collected on the remote).

ACKs for top commit:
  Sjors:
    ACK fa94fd53c9
  l0rinc:
    ACK fa94fd53c9
  willcl-ark:
    ACK fa94fd53c9
  rkrux:
    ACK fa94fd53c9
  janb84:
    ACK fa94fd53c9

Tree-SHA512: b68c0c612e13f501ad4c1c709502e060b0a2d0eb55ef888c7466e2a10bdf3ca63d81b8bd7927de49cde9e29f0b06f8233d51b99d015ae0b39d556854be542b8a
This commit is contained in:
merge-script
2025-06-19 12:32:30 +01:00

View File

@@ -19,6 +19,7 @@ Table of Contents
* [More conflict context with `merge.conflictstyle diff3`](#more-conflict-context-with-mergeconflictstyle-diff3)
* [Reviewing code](#reviewing-code)
* [Reduce mental load with `git diff` options](#reduce-mental-load-with-git-diff-options)
* [Fetch commits directly](#fetch-commits-directly)
* [Reference PRs easily with `refspec`s](#reference-prs-easily-with-refspecs)
* [Diff the diffs with `git range-diff`](#diff-the-diffs-with-git-range-diff)
@@ -164,9 +165,17 @@ When reviewing patches that change symbol names in many places, use `git diff --
When reviewing patches that move code around, try using `git diff --patience commit~:old/file.cpp commit:new/file/name.cpp`, and ignoring everything except the moved body of code which should show up as neither `+` or `-` lines. In case it was not a pure move, this may even work when combined with the `-w` or `--word-diff` options described above. `--color-moved=dimmed-zebra` will also dim the coloring of moved hunks in the diff on compatible terminals.
### Fetch commits directly
Before inspecting any remotely created commit locally, it has to be fetched.
This is possible via `git fetch origin <full_commit_hash>`. Even commits not
part of any branch or tag can be fetched as long as the remote has not garbage
collected them.
### Reference PRs easily with `refspec`s
When looking at other's pull requests, it may make sense to add the following section to your `.git/config` file:
As an alternative to fetching commits directly, when looking at pull requests by others, it may make sense to add the following section to your `.git/config` file:
```
[remote "upstream-pull"]