Git: hide/remove files never to be versioned

In case you have files already added to the repository, but need to remove/ignore them, follow these steps:

  1. Move those files somewhere out of the repository.
  2. Make a commit, which would delete those files from the repository
  3. Move those files back to the repository to the place where they have been
  4. Make a commit, but now instead of adding those files to the repository, right click on those files. Select Add to ignore listBy file name. The option to which .gitignore you add those is irrelevant, but you can look up the difference on the Internet.

Create a text file called .gitignore in your root folder and add lines like the following to exclude files:

*.obj
test.c

Then add .gitignore to your Git repository and commit:

$ git add .gitignore
$ git commit .gitignore

You need to investigate .gitignore files.

git help gitignore

TortoiseGit can add files to the ignore list with many options.

Right click on a file in a repository → TortoiseGitAdd to ignore list → by filename / by extension

A dialog shows to choose options:

Ignore type

This file only (match absolute name),

Recursive (match same name)

Ignore file

.gitignore in root directory (need to commit)

.gitignore in included directory (need to commit)

.git/info/exclude (like a configuration file, stored locally)

See also: Manual entry, Chapter 2. TortoiseGit Daily Use Guide, Ignoring Files And Directories.