Ignoring Files

In almost any project there will be some files that you don't want to include in version control - e.g. automatically created files from builds, caches or logs, or platform-specific files like OS X's ".DS_Store" files. Git offers a couple of different options in this context.

Ignoring & Excluding Files

When you choose to ignore a file or folder, Git keeps note of this in a file called .gitignore. It is part of your project's files and is therefore version controlled like any other item. This means that ignore rules are shared with and valid for everybody that works with this repository.

If you want these rules to only have an effect on your own machine, you can exclude the item instead. Exclude rules are not version controlled and are therefore neither affecting other team members nor even shared with anyone else.

Only Untracked Files are Ignored
Please note that both "ignore" and "exclude" only have an effect on untracked files - files that are not already included in version control. Therefore, it's best to ignore files before they are checked into version control, right at the beginning of a project. If they have been accidentally added already, you will need to untrack them, commit and then ignore/exclude them.

In Tower, ignoring and excluding a file works very similar: right-click the corresponding file or folder in the Working Copy file listing and choose one of the options from the Ignore or Exclude menu:

  • "Ignore/Exclude": the created ignore rule will only concern this very item at this path
  • "Ignore/Exclude All Items Like This": the created ignore rule will match all items with the same name (also in other folders in this repository)
  • "Create Ignore/Exclude Pattern From Item": Tower just suggests an ignore rule as a starting point and allows you to modify it before it's added

Displaying Ignored Files

By default, ignored files are not displayed in the file listings in your Working Copy, anymore. In case you should ever need to see them, you can activate the display of ignored files as follows: in the "Working Copy Status" submenu (in the main "View" menu), make sure that both View as Tree and Show Ignored Items are activated.

Ignored Files in Tower's "View as Tree" Mode
If you're using the "View as Tree" mode in Tower's Working Copy view, please be aware of the following: files inside of untracked folders are displayed in any case - even if they are ignored! As soon as you stage the parent folder (changing its state from "untracked" to "added"), any applicable ignore rules will come into effect.

Viewing & Editing Existing Ignore Patterns

Git keeps a list of file patterns it shall ignore - in ".gitignore" and ".git/info/excludes" in your repository. You can edit these entries by opening the repository's Settings view in Tower's sidebar. Here, ignored & excluded paths are listed and can be edited in an external editor by clicking the Edit button on the right of the row.

Marking Files as "Assume-Unchanged"

There might be cases when you want to modify a file but not have these modifications committed to the repository. And, since this file might be already tracked, you cannot or don't want to ignore it.
This is when Git's "assume-unchanged" flag comes in handy. You can mark a file with this flag and thereby have Git ignore local changes for it.

In Tower, you can achieve this by right-clicking the file and selecting Set Assume-Unchanged from the Mark submenu.