Skip to content

Commit 3144449

Browse files
committed
Add git and github tips and tricks to developer notes
1 parent 66ed450 commit 3144449

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

doc/developer-notes.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,51 @@ GUI
381381
- *Rationale*: Model classes pass through events and data from the core, they
382382
should not interact with the user. That's where View classes come in. The converse also
383383
holds: try to not directly access core data structures from Views.
384+
385+
Git and github tips
386+
---------------------
387+
388+
- For resolving merge/rebase conflicts, it can be useful to enable diff3 style using
389+
`git config merge.conflictstyle diff3`. Instead of
390+
391+
<<<
392+
yours
393+
===
394+
theirs
395+
>>>
396+
397+
you will see
398+
399+
<<<
400+
yours
401+
|||
402+
original
403+
===
404+
theirs
405+
>>>
406+
407+
This may make it much clearer what caused the conflict. In this style, you can often just look
408+
at what changed between *original* and *theirs*, and mechanically apply that to *yours* (or the other way around).
409+
410+
- When reviewing patches which change indentation in C++ files, use `git diff -w` and `git show -w`. This makes
411+
the diff algorithm ignore whitespace changes. This feature is also available on github.com, by adding `?w=1`
412+
at the end of any URL which shows a diff.
413+
414+
- When reviewing patches that change symbol names in many places, use `git diff --word-diff`. This will instead
415+
of showing the patch as deleted/added *lines*, show deleted/added *words*.
416+
417+
- When reviewing patches that move code around, try using
418+
`git diff --patience commit~:old/file.cpp commit:new/file/name.cpp`, and ignoring everything except the
419+
moved body of code which should show up as neither `+` or `-` lines. In case it was not a pure move, this may
420+
even work when combined with the `-w` or `--word-diff` options described above.
421+
422+
- When looking at other's pull requests, it may make sense to add the following section to your `.git/config`
423+
file:
424+
425+
[remote "upstream-pull"]
426+
fetch = +refs/pull/*:refs/remotes/upstream-pull/*
427+
url = [email protected]:bitcoin/bitcoin.git
428+
429+
This will add an `upstream-pull` remote to your git repository, which can be fetched using `git fetch --all`
430+
or `git fetch upstream-pull`. Afterwards, you can use `upstream-pull/NUMBER/head` in arguments to `git show`,
431+
`git checkout` and anywhere a commit id would be acceptable to see the changes from pull request NUMBER.

0 commit comments

Comments
 (0)