Skip to content
Versora

Manual

Changes

Ignoring files and .gitignore templates

8 min read

On this page

.gitignore is the file, at the root of the repository, that lists what git should pretend not to see: build folders, downloaded dependencies, logs, editor files, local secrets such as .env. An ignored file disappears from the changes panel and isn't included in Stage all changes.

Versora offers two ways: ignore a file from the list right away (the file, its extension or its folder) and add at once a template with the typical patterns of a language, a framework, an editor or an operating system.

Tip

.gitignore is a repository file like any other: after you change it, it appears in Unstaged files and needs to be committed to apply to the team.

Ignore a file, an extension or a folder

Adds to .gitignore a pattern made from the chosen file. If the file was already tracked by git, Versora also removes it from git (without deleting it from disk); without that, it would keep appearing, despite the pattern.

Where to find it

  • File menu in Unstaged files › Ignore › (submenu).

The submenu changes depending on the file. For logs/app/servidor.log:

ItemPattern addedWhen it appears
servidor.log (untracked file)/logs/app/servidor.logAlways.
servidor.log — ignore and stop tracking (already tracked file)/logs/app/servidor.logInstead of the previous one, when git already tracks the file.
All .log files*.logWhen the name has an extension.
Everything in folder logs/app//logs/app/When the file is in a folder.
.gitignore templates…(opens the templates window)Always, after a separator.

The leading / anchors the pattern to the repository root: /logs/app/ ignores that folder, and not any logs/app folder somewhere else. The characters .gitignore would treat as wildcards (*, ?, [, ] and \) in the file or folder name are escaped with \.

Step by step

  1. In the changes panel, right-click logs/app/servidor.log, in the Unstaged files section.
  2. Point to Ignore and choose, for example, All .log files.
  3. The toolbar shows "Updating .gitignore…" and, at the end, "Added "*.log" to .gitignore" appears.
  4. The .log files disappear from the list. The .gitignore appears in Unstaged files: stage it and commit.

What Versora does in git

  1. It reads the .gitignore at the repository root (or starts an empty one, if it doesn't exist yet).
  2. If the pattern isn't there yet (comparing line by line), it appends it at the end, with the same line ending the file already uses (CRLF or LF).
  3. On an already tracked file, it removes it from git without deleting it from disk:
bash
echo "*.log" >> .gitignore
git --literal-pathspecs rm -r -q --cached --ignore-unmatch -- logs/app/servidor.log

How to undo

Ctrl+Z doesn't undo this operation. To go back:

  • open the .gitignore (for example, from its diff, with Edit file) and delete the line; or discard the .gitignore changes, if it had no others (see Discarding changes);
  • on a file that stopped being tracked, the removal appears in Staged files as a deletion: unstage it (see Staging) for git to track the file again.

Caveats and messages

  • "ignore and stop tracking" doesn't delete the file from disk, but the next commit records its deletion in the repository. For anyone who pulls that commit, git deletes the file from their working copy. Tell the team before you stop tracking a file other people use (for example, a local configuration).
  • With All .log files or Everything in folder logs/app/ on a tracked file, only that file leaves git. Other already tracked files that match the pattern stay tracked (.gitignore only applies to files git doesn't track yet).
  • The pattern always goes into the .gitignore at the repository root, even if there are other .gitignore files in subfolders.
  • "Invalid ignore pattern.": the pattern ended up empty or with a line break.
  • "Couldn't read the .gitignore: …" / "Couldn't write the .gitignore: …": the file is locked by another program or there's no permission.
  • The Ignore submenu doesn't appear for conflicted files or for those in the Staged files section.

See also

.gitignore templates

A window with ready-made templates, built into Versora (nothing is downloaded), with the most used patterns of each language, framework, tool and operating system. You check one or more and see, before writing, exactly the lines that will go into the file. The ones the .gitignore already has are left out.

Where to find it

  • File menu › Ignore › .gitignore templates…
  • Palette (Ctrl+P): ".gitignore templates…" (also found by "gitignore", "ignore" or "template").
  • When creating a repository: the .gitignore template (optional) field (next section).

The available templates

GroupTemplates
LanguagesNode, Python, Java, Kotlin, .NET / Visual Studio, Rust, Go, C / C++, PHP / Composer, Ruby / Rails, Swift / Xcode
FrameworksAndroid, Laravel, Dart / Flutter, Unity
Tools and editorsMaven, Gradle, Terraform, Visual Studio Code, JetBrains (IntelliJ, Rider…), Vim
Operating systemsWindows, macOS, Linux

Some examples of what each one brings:

TemplateSome of the lines
Nodenode_modules/, npm-debug.log*, dist/, build/, coverage/, *.tsbuildinfo, .env, .env.local
Python__pycache__/, *.py[cod], .venv/, venv/, .pytest_cache/, .mypy_cache/, htmlcov/, .env
.NET / Visual Studio[Bb]in/, [Oo]bj/, [Dd]ebug/, [Rr]elease/, .vs/, *.user, *.suo, TestResults/, *.nupkg
Java*.class, *.log, *.jar, *.war, *.ear, hs_err_pid*
Rusttarget/, **/*.rs.bk, *.pdb
Go*.exe, *.dll, *.so, *.test, *.out, go.work, vendor/
Unity/[Ll]ibrary/, /[Tt]emp/, /[Oo]bj/, /[Bb]uild/, /[Ll]ogs/, *.csproj, *.sln
Visual Studio Code.vscode/*, !.vscode/settings.json, !.vscode/tasks.json, !.vscode/launch.json, *.code-workspace
WindowsThumbs.db, Desktop.ini, $RECYCLE.BIN/, *.lnk, *.stackdump
macOS.DS_Store, .AppleDouble, ._*, .Spotlight-V100, .Trashes

The full list of each template appears in the window itself, when you check it.

Step by step

  1. Open the .gitignore templates window (from the palette, for example).
  2. Type in Filter templates to find one quickly (for example, "py"). With no result, "No template with that name." appears.
  3. Check one or more templates: Node and Windows, for example.
  4. On the right, Lines that will be added shows the exact block, with one comment per template (# Node, # Windows). The summary says, for example, "18 new lines (6 already there)".
  5. Click Add to .gitignore (or Create .gitignore, if the repository doesn't have one yet). The toolbar shows "Writing the .gitignore…" and, at the end, "18 lines added to the .gitignore".
  6. Stage the .gitignore and commit.
OptionWhat it doesDefault
Filter templatesShows only the templates whose name contains the text.Empty
Template checkboxesMark the templates that go in. The block's order follows the list's order.None checked

What Versora does in git

No git command: the app edits the file.

  1. It reads the .gitignore at the root.
  2. It builds the block: for each checked template, a # <template name> comment and only the lines that don't exist yet in the file (lines are compared without leading and trailing spaces, ignoring comments) or in a previous template of the same choice.
  3. It appends the block at the end of the file, separated from the previous content by a blank line, with the same line ending the file uses.
  4. If the file didn't exist, it creates it.

For example, in a .gitignore that already has node_modules/, checking Node adds:


# Node
npm-debug.log*
yarn-debug.log*
...
.env.*.local

How to undo

  • With an already existing .gitignore: Ctrl+Z restores the previous content ("Undo: Templates in .gitignore (Ctrl+Z)").
  • With a new .gitignore (created by the window): Ctrl+Z doesn't delete it. Nothing is lost: the file appears in the changes, and you can discard it like any new file (see Discarding changes).

Caveats and messages

  • "Nothing to add: the .gitignore already has all 17 lines.": all the lines of the checked templates are already in the file. The button is disabled.
  • "Check one or more templates to see what goes in.": nothing checked yet.
  • "The .gitignore changed while the window was open. Open it again to see the current version.": another program wrote the file after the window read it. So as not to overwrite it, Versora refuses; close the window and open it again.
  • "The .gitignore is too large to edit here.": the file is over 2 MB.
  • "Couldn't read the .gitignore: …" / "Couldn't write the .gitignore: …": file locked or no permission.
  • Templates only keep new files out of git. Files that are already in the repository (a node_modules committed by mistake, for example) stay tracked; to remove them, use Ignore › "… — ignore and stop tracking" on each one, or git rm -r --cached <folder> in the terminal.
  • .env is in the Node, Python, PHP / Composer, Laravel and Ruby / Rails templates. To detect secrets that have already been staged, see Checks.
  • Esc or a click outside the window close it without writing.

See also

.gitignore template when creating a repository

When you create a new repository with Versora, you can already choose a template, and the .gitignore is born together with the repository.

Where to find it

Step by step

  1. Open the New repository (init) dialog.
  2. Fill in Create in, Folder name and Initial branch.
  3. In .gitignore template (optional), choose a template from the list (in alphabetical order), for example Python. None (the default) doesn't create the file.
  4. Click Create repository.
OptionWhat it doesDefault
.gitignore template (optional)Creates the .gitignore with the # <template> comment and the template's lines. Only one template at a time; to combine others, use the .gitignore templates window afterwards.None

What Versora does in git

It writes the .gitignore and, if the repository only has the initial commit the app has just created (the Create README.md and the initial commit option), includes the file in that commit:

bash
git add -- .gitignore
git commit -q --amend --no-edit --no-verify

Without the initial commit, the .gitignore stays in the changes, waiting for the first commit.

Caveats and messages

  • "The repository already has a .gitignore.": the chosen folder already had a .gitignore; it isn't replaced. Use the .gitignore templates window to add lines.

See also