git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: .gitignore is not enough

From
Johannes Sixt <j6t@kdbg.org>
Date
Aug 3, 2023, 17:17 UTC
Message-ID
<c2fea20d-af37-8721-5bd8-14bbc3daf937@kdbg.org>
In-Reply-To
<CAE1pOi1Zt8i_rVi6dCGVsshhPxa_kV7qQ7SMu6R4nsSiadq7xw@mail.gmail.com>
Am 03.08.23 um 07:35 schrieb Hilco Wijbenga:
> I think you might be looking for "git update-index --assume-unchanged
> <file>"? See https://www.git-scm.com/docs/git-update-index for more
> details.

Sorry to tell you that this is a myth that lives on because it is repeated over and over again.

> This allows you to tell Git to ignore the changes you made to that
> (tracked) file.

No. --assume-unchanged allows you to make the *promise* to Git that you will not change the file, and consequently Git does not have to check whether the file was changed. If you break the promise (because you change it), you will get what you deserve. For example, you may find that Git overwrites your changes, or commits them nevertheless.

Perhaps a better choice is --skip-worktree, but recent answers on Stackoverflow point out that even that is not a suitable solution for "please, Git, ignore these changes".

-- Hannes
Previous: Hilco WijbengaNext: Hilco Wijbenga
Message 3 of 8 in “.gitignore is not enough”
  1. Aleem ZakiAug 3, 2023
  2. Hilco WijbengaAug 3, 2023
  3. Johannes SixtAug 3, 2023
  4. Hilco WijbengaAug 3, 2023
  5. Johannes SixtAug 3, 2023
  6. Junio C HamanoAug 3, 2023
  7. brian m. carlsonAug 3, 2023
  8. Aleem ZakiAug 3, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.