Skip to content

Instantly share code, notes, and snippets.

@jabielecki
Last active February 26, 2024 08:03
Show Gist options
  • Save jabielecki/fb8013909e55e4ad66e1282e79c5c186 to your computer and use it in GitHub Desktop.
Save jabielecki/fb8013909e55e4ad66e1282e79c5c186 to your computer and use it in GitHub Desktop.
In Jujutsu restore `.gitignore` file from a revision

With github.com/martinvonz/jj (Jujutsu), there is a common failure mode:

You checkout too far back into the history where the .gitignore does not catch anymore your large files and you become stuck forever with:

$ jj show
Error: Failed to snapshot the working copy: New file very/big/file of size ~922.4MiB exceeds snapshot.max-new-file-size (1.0MiB)

If it's just one big file, no biggie:

$ echo very/big/file >> .gitignore

It's much harder if you placed a lot of different big files around your repo. How to rollback the situation and go back to a known my_good_branch containing a proper .gitignore:

$ jj checkout my_good_branch --ignore-working-copy

$ git checkout .gitignore
Updated 1 path from the index

$ jj workspace update-stale 
Done importing changes from the underlying Git repo.
Concurrent modification detected, resolving automatically.

Done.

$ jj version
jj 0.13.0-5450e6c9bae40b941b05942bdd78a88e1b9093a6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment