Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Artifact Files You Should Have Ignored

Use Case

○  h
○  g
│ ○  f
│ ○  e
│ ○  d
│ ○  c
├─╯
○  b  <- Binary files added the first time here
○  a
◆
  • You rebase.
jj rebase -s c -o h
×  f
×  e
×  d
×  c
○  h
○  g
○  b  <- Binary files added the first time here
○  a
◆
  • Conflicts.
  • The conflict involves .bin files that should have been Git ignored from the start.

Solution

The idea is:

  • Git ignore the binary files in the Change where they were initially added.
  • Move all the edits to .bin in a temporary Change, then abandon it.

Here’s how:

  • Find the Change that originally added .bin:
jj log -r 'files(".bin")'
  • Create a Buffer Change on top of it:
jj new -r b
  • Add the missing item to .gitignore:
echo .bin/ >> .gitignore
jj squash
  • Collect all edits to .bin from the whole history into a temporary Change:
jj squash -f 'files(".bin")' bin
  • Abandon the temporary Change:
jj abandon