diff mbox series

[v4,4/5] doc: dissuade users from trying to ignore tracked files

Message ID 20200120173343.4102954-5-sandals@crustytoothpaste.net (mailing list archive)
State New, archived
Headers show
Series Documentation for common user misconceptions | expand

Commit Message

brian m. carlson Jan. 20, 2020, 5:33 p.m. UTC
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 addition, 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>
---

Peff, since I've adopted a significant portion of what you've said here,
it's probably worth getting your sign-off on this patch.

 Documentation/git-update-index.txt | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Jeff King Jan. 20, 2020, 5:54 p.m. UTC | #1
On Mon, Jan 20, 2020 at 05:33:42PM +0000, brian m. carlson wrote:

> Peff, since I've adopted a significant portion of what you've said here,
> it's probably worth getting your sign-off on this patch.

Sure thing:

  Signed-off-by: Jeff King <peff@peff.net>

And the patch itself looks good to me.

-Peff
diff mbox series

Patch

diff --git a/Documentation/git-update-index.txt b/Documentation/git-update-index.txt
index c7a6271daf..1489cb09a0 100644
--- a/Documentation/git-update-index.txt
+++ b/Documentation/git-update-index.txt
@@ -549,6 +549,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.
+
+For example, if the file you want to change is some sort of config file,
+the repository can include a sample config file that can then be copied
+into the ignored name and modified.  The repository can even include a
+script to treat the sample file as a template, modifying and copying it
+automatically.
+
 SEE ALSO
 --------
 linkgit:git-config[1],