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

[PATCH v3 3/4] doc: dissuade users from trying to ignore tracked files

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Nov 2, 2019, 19:26 UTC
Message-ID
<20191102192615.10013-4-sandals@crustytoothpaste.net>
In-Reply-To
<20191102192615.10013-1-sandals@crustytoothpaste.net>

It is quite common for users to want to ignore the changes to a file that Git tracks. Common scenarios for this case are IDE settings and configuration files, which should generally not be tracked and possibly generated from tracked files using a templating mechanism.

However, users learn about the assume-unchanged and skip-worktree bits and try to use them to do this anyway. This is problematic, because when these bits are set, many operations behave as the user expects, but they usually do not help when git checkout needs to replace a file.

There is no sensible behavior in this case, because sometimes the data is precious, such as certain configuration files, and sometimes it is irrelevant data that the user would be happy to discard.

Since this is not a supported configuration and users are prone to misuse the existing features for unintended purposes, causing general sadness and confusion, let's document the existing behavior and the pitfalls in the documentation for git update-index so that users know they should explore alternate solutions.

In additon, let's provide a recommended solution to dealing with the common case of configuration files, since there are well-known approaches used successfully in many environments.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/git-update-index.txt | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index 1c4d146a41..11230376c8 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -543,6 +543,22 @@ The untracked cache extension can be enabled by the
 `core.untrackedCache` configuration variable (see
 linkgit:git-config[1]).
 
+NOTES
+-----
+
+Users often try to use the ``assume unchanged'' and skip-worktree bits
+to tell Git to ignore changes to files that are tracked.  This does not
+work as expected, since Git may still check working tree files against
+the index when performing certain operations.  In general, Git does not
+provide a way to ignore changes to tracked files, so alternate solutions
+are recommended.
+
+If the file you want to change is some sort of configuration file (say,
+for a build tool, IDE, or editor), a common solution is to use a
+templating mechanism, such as Ruby's ERB, to generate the ignored
+configuration file from a template stored in the repository and a source
+of data using a script or build step.
+
 SEE ALSO
 --------
 linkgit:git-config[1],
Previous: brian m. carlsonNext: rsbecker@nexbridge.com
Message 5 of 25 in “Documentation for common user misconceptions”
  1. 0/4 Documentation for common user misconceptionsbrian m. carlson, Nov 2, 2019
  2. 2/4 doc: provide guidance on user.name formatbrian m. carlson, Nov 2, 2019
  3. Jakub NarebskiNov 3, 2019
  4. brian m. carlsonNov 3, 2019
  5. 3/4 doc: dissuade users from trying to ignore tracked filesbrian m. carlson, Nov 2, 2019
  6. rsbecker@nexbridge.comNov 2, 2019
  7. Jakub NarebskiNov 3, 2019
  8. Jakub NarebskiNov 3, 2019
  9. brian m. carlsonNov 3, 2019
  10. Jakub NarebskiNov 3, 2019
  11. brian m. carlsonNov 3, 2019
  12. Jakub NarebskiNov 5, 2019
  13. Jeff KingNov 4, 2019
  14. brian m. carlsonNov 4, 2019
  15. 4/4 docs: mention when increasing http.postBuffer is valuablebrian m. carlson, Nov 2, 2019
  16. 1/4 doc: move author and committer information to git-commit(1)brian m. carlson, Nov 2, 2019
  17. Jakub NarebskiNov 3, 2019
  18. Jeff KingNov 4, 2019
  19. Junio C HamanoNov 6, 2019
  20. Jeff KingNov 4, 2019
  21. Junio C HamanoNov 6, 2019
  22. brian m. carlsonNov 6, 2019
  23. Junio C HamanoNov 6, 2019
  24. Emily ShafferJan 16, 2020
  25. brian m. carlsonJan 16, 2020

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.