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

Excluding files from version control

Reset your progress

To reset your progress to the start of this chapter, run the following command:

curl https://s2p2.github.io/jj-for-everyone/reset.sh | bash -s ignore
cd ~/jj-tutorial/repo

Let's switch to Bob's repository.

cd ~/jj-tutorial/repo-bob

Done with his part of the assignment, he's already thinking about the submission. The teacher expects to receive a tarball called submission_alice_bob.tar.gz. After a little trial and error, he comes up with the following command to create the tarball:

tar czf submission_alice_bob.tar.gz README.md

(Go ahead and run it!)

Bob wants to spare Alice the hassle of having to figure that out, in case she ends up making the final submission. He decides to add it to the documentation:

echo "
## Submission

Run the following command to create the submission tarball:

~~~sh
tar czf submission_alice_bob.tar.gz [FILE...]
~~~" >> README.md

Bob is careful to push only clean commits to the remote shared with Alice. (Be like Bob!) He double-checks the content of his commit with jj show:

Commit ID: 596961f1e4aaa66f50b918902efbc839122184f4
Change ID: vtkxsvmtporzvtpovlpqvytrpzxyuykn
Author   : Bob <bob@local> (2025-08-04 20:38:40)
Committer: Bob <bob@local> (2025-08-04 20:38:59)

    (no description set)

Modified regular file README.md:
    ...
   3    3: The file hello.py contains a script that greets the world.
   4    4: It can be executed with the command 'python hello.py'.
   5    5: Programming is fun!
        6: 
        7: ## Submission
        8: 
        9: Run the following command to create the submission tarball:
       10: 
       11: ~~~sh
       12: tar czf submission_alice_bob.tar.gz [FILE...]
       13: ~~~
Added regular file submission_alice_bob.tar.gz:
    (binary)

Oh no! It looks like the result of Bob's research was recorded in the commit. The tarball submission_alice_bob.tar.gz should not be tracked in version control.

To exclude files, use a .gitignore file. It can contain file names, directories, and patterns for files to ignore.

Add a pattern for tarballs to .gitignore. The * is a glob that matches any filename.

echo "*.tar.gz" > .gitignore

Ignoring files globally

To ignore files across all projects, add them to a global ignore file. This is useful for editor-specific or OS-specific files like .DS_Store on macOS.

echo ".DS_Store" >> ~/.gitignore

Let's check the commit again.

Commit ID: c9bc30b48922c767c553392709f212b8c0815ceb
Change ID: vtkxsvmtporzvtpovlpqvytrpzxyuykn
Author   : Bob <bob@local> (2025-08-04 20:38:40)
Committer: Bob <bob@local> (2025-08-04 20:41:13)

    (no description set)

Added regular file .gitignore:
        1: *.tar.gz
Modified regular file README.md:
    ...
   3    3: The file hello.py contains a script that greets the world.
   4    4: It can be executed with the command 'python hello.py'.
   5    5: Programming is fun!
        6: 
        7: ## Submission
        8: 
        9: Run the following command to create the submission tarball:
       10: 
       11: ~~~sh
       12: tar czf submission_alice_bob.tar.gz [FILE...]
       13: ~~~
Added regular file submission_alice_bob.tar.gz:
    (binary)

The tarball is still tracked. Jujutsu only considers .gitignore for new, untracked files.

To stop tracking an already-tracked file, use jj file untrack.

jj file untrack submission_alice_bob.tar.gz

The untrack command only works if the file is already listed in .gitignore.

Let's check the commit one more time.

Commit ID: 0f0015beb53d8c83f3bbcfe938a9bf031834c3e4
Change ID: vtkxsvmtporzvtpovlpqvytrpzxyuykn
Author   : Bob <bob@local> (2025-08-04 20:38:40)
Committer: Bob <bob@local> (2025-08-04 20:41:36)

    (no description set)

Added regular file .gitignore:
        1: *.tar.gz
Modified regular file README.md:
    ...
   3    3: The file hello.py contains a script that greets the world.
   4    4: It can be executed with the command 'python hello.py'.
   5    5: Programming is fun!
        6: 
        7: ## Submission
        8: 
        9: Run the following command to create the submission tarball:
       10: 
       11: ~~~sh
       12: tar czf submission_alice_bob.tar.gz [FILE...]
       13: ~~~

The commit is clean. Now, add a description.

jj commit -m "Add submission instructions"