Skip to content

Commit fd7d97d

Browse files
author
MarcoFalke
committed
Merge #15820: docs: Add productivity notes for dummy rebases
01971da docs: Add productivity notes for "dummy rebases" (Carl Dong) Pull request description: When rebasing, we often want to do a "dummy rebase" whereby we are not rebasing over an updated master. This is because rebases can be confusing enough already, and we don't want to resolve upstream conflicts together with our local rebase conflicts due to fixup commits, commit rearrangements, and such. This productivity section details how to do such "dummy rebase"s. ACKs for commit 01971d: Tree-SHA512: 241a451cec01dc9a01a2286bdee1441cac6d28007f5b173345744d2abf436da916c3f2553ff0d1c5b3687055107b37872dda9529288645e4bae7b3cb46923b7e
2 parents 376638a + 01971da commit fd7d97d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

doc/productivity.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Table of Contents
1010
* [Make use of your threads with `make -j`](#make-use-of-your-threads-with-make--j)
1111
* [Only build what you need](#only-build-what-you-need)
1212
* [Multiple working directories with `git worktrees`](#multiple-working-directories-with-git-worktrees)
13+
* [Interactive "dummy rebases" for fixups and execs with `git merge-base`](#interactive-dummy-rebases-for-fixups-and-execs-with-git-merge-base)
1314
* [Writing code](#writing-code)
1415
* [Format C/C++/Protobuf diffs with `clang-format-diff.py`](#format-ccprotobuf-diffs-with-clang-format-diffpy)
1516
* [Format Python diffs with `yapf-diff.py`](#format-python-diffs-with-yapf-diffpy)
@@ -93,6 +94,21 @@ To simply check out a commit-ish under a new working directory without disruptin
9394
git worktree add --checkout ../where-my-checkout-commit-ish-will-live my-checkout-commit-ish
9495
```
9596

97+
### Interactive "dummy rebases" for fixups and execs with `git merge-base`
98+
99+
When rebasing, we often want to do a "dummy rebase," whereby we are not rebasing over an updated master but rather over the last common commit with master. This might be useful for rearranging commits, `rebase --autosquash`ing, or `rebase --exec`ing without introducing conflicts that arise from an updated master. In these situations, we can use `git merge-base` to identify the last common commit with master, and rebase off of that.
100+
101+
To squash in `git commit --fixup` commits without rebasing over an updated master, we can do the following:
102+
103+
```sh
104+
git rebase -i --autosquash "$(git merge-base master HEAD)"
105+
```
106+
107+
To execute `make check` on every commit since last diverged from master, but without rebasing over an updated master, we can do the following:
108+
```sh
109+
git rebase -i --exec "make check" "$(git merge-base master HEAD)"
110+
```
111+
96112
-----
97113

98114
This synergizes well with [`ccache`](#cache-compilations-with-ccache) as objects resulting from unchanged code will most likely hit the cache and won't need to be recompiled.

0 commit comments

Comments
 (0)