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
.binfiles 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
.binin 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
.binfrom the whole history into a temporary Change:
jj squash -f 'files(".bin")' bin
- Abandon the temporary Change:
jj abandon