git
created ... ago
updated ... ago
#resource

Configuring git

# ~/.config/git/config
[alias]
  hist = "rebase --keep-base main -i"
  up = "push --force-with-lease"

[rebase]
  updateRefs = true

Workflow

(main)> git switch -C feat-a

Work on it, make commits. When you're done, push it and make a pull request

(feat-a)> git switch -C feat-b

Start working on a new feature that depends on feat-a before it's merged. When the feedback comes:

(feat-b)> git commit -pm "fix: whatever in feat-a was fixed"
(feat-b)> git hist

It will open a history editor:

pick e7d5b8c # commit from feat-a

# branch feat-a ↑
update-ref refs/heads/feat-a
# branch feat-b ↓

pick 484e130 # commit from feat-b
pick fffa0a1 # fix: whatever in feat-a was fixed

Move the last line above update-ref and git will move the commit to feat-a.

Push feat-a using without ever switching to it:

(feat-b)> git up origin feat-a

When feat-a gets merged, delete it from history:

(feat-b)> git fetch
(feat-b)> git rebase feat-a --onto origin/main

Refs

https://www.codetinkerer.com/2023/10/01/stacked-branches-with-vanilla-git.html