threads / discuss / 42364

Ignore updates to files which are ignored, even if they're indexed.

Subject: Ignore updates to files which are ignored, even if they're indexed.

## tl;dr

2 messages between May 18, 2016 and May 18, 2016.

replies: 1people: 2as markdown or json

Josh McCullough· May 18, 2016, 01:07 UTC · lore

TL;DR: Git should ignore files if they are in `.gitignore`, regardless of whether or not the file has changed (or been removed).

Use Case

An initial set of "local" config files are committed to a repo. Each developer will pull down this set of files, but changes will be auto-ignored unless the file is force-added after a change is made.

Current Workarounds
1) Use `git update-index --assume-unchanged local-config.xyz` to
ignore local changes to the file.
2) Add templates instead (local-config.template.xyz) and tell each
developer to copy these templates and remove the ".template" portion
of the file name. The file name without the ".template" portion is
added to `.gitignore`.

The current workarounds rely on the developer to know/remember what to do. It would be nice if we could do this instead:

1) Create the initial `config-local.xyz`.
2) Add the new file to the index (`git add`).
3) Add the same path to `.gitignore`, and add the changes to the index.
4) Commit the staged changes.
5) Edit the `config-local.xyz` file.
6) Run `git status` -- git will not suggest that the file was changed
since it is in the `.gitignore`. If 7) The user specifically made
changes they wish to commit, the can force-add the ignored file.

Doing a search for [git commit file only once then ignore changes] will show that other people wish for the same feature.

Thanks!
----- ----- -----

Side note: It took me 4 tries to get this email to go through, since non-plain-text messages are strictly forbidden by this mailing list. I use Inbox, which doesn't have an option to ensure a message is sent as plain text. I had to switch back to GMail to get it to go through.

Johannes Schindelin· May 18, 2016, 06:38 UTC · re: Josh McCullough · lore

Re: Ignore updates to files which are ignored, even if they're indexed.

Hi Josh,
On Tue, 17 May 2016, Josh McCullough wrote:
> TL;DR: Git should ignore files if they are in `.gitignore`, regardless
> of whether or not the file has changed (or been removed).

This would break at least one of my setups, where I was too lazy to add negative rules to .gitignore.

I imagine that I am not the only one relying on the current behavior. Which means that you would need to tread very carefully should you choose to work on this.

Besides, it sounds like you want certain files to be "tracked a little", and at the same time be "untracked a little".

Maybe there is a better solution. Would you care to describe your use case in more detail, in particular the goal?

Ciao, Johannes

← back to recent threads