From: Jonathan Nieder <jrnieder@gmail.com>
To: Nevada Sanchez <sanchez.nevada@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Bug with .gitignore and branch switching
Date: Fri, 17 Mar 2017 14:54:42 -0700 [thread overview]
Message-ID: <20170317215442.GN26789@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <CAPUVn2u0Uos2mT5+4ejj8m0okNK6XwerL6ce2miHfhtuEs-ZnQ@mail.gmail.com>
Hi Nevada,
Nevada Sanchez wrote:
> # Commit a file that will end up in .gitignore
> echo 'original settings' > mine.conf
> git add mine.conf
> git commit -m "Unknowingly committed my settings."
>
> echo '*.conf' > .gitignore
> git add .gitignore
> git commit -m "Users shouldn't commit their settings"
Naming a file in .gitignore tells git that you do not want to track it
and are giving git permission to write over it. This commonly happens
when people check in build products. For example:
git rm -f my-build-product
echo /my-build-product >>.gitignore
git commit -m "Remove generated my-build-product file"
make my-build-product
git checkout HEAD^
Without that rule, this 'git checkout' command would fail.
That said, there are some cases (e.g. the .conf file case you mention)
where a person would want git not to track a file but do not want to
give git permission to write over it. As you've seen, .gitignore does
not work well for this. :/
Ideas for next steps:
1. The gitignore(5) manpage does not do a good job of emphasizing
that files named there are not precious and can be overwritten by
git. Do you have ideas for wording that would help with that?
This would be especially welcome if you can phrase them in the
form of a patch against Documentation/gitignore.txt.
2. Occasionally people have mentioned the idea of a .gitprecious file
listing precious files that git should not track and not overwrite
(e.g., keys and other configuration files, IDE state, or metadata
for another version control system being used in parallel). Would
you be interested in working on that?
Thanks and hope that helps,
Jonathan
prev parent reply other threads:[~2017-03-17 21:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 20:42 Bug with .gitignore and branch switching Nevada Sanchez
2017-03-17 21:23 ` Junio C Hamano
2017-03-17 21:58 ` Stefan Beller
2017-03-17 22:02 ` Jonathan Nieder
2017-03-17 22:36 ` Junio C Hamano
2017-03-18 3:40 ` Duy Nguyen
2017-03-18 4:30 ` Nevada Sanchez
2017-03-17 21:54 ` Jonathan Nieder [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170317215442.GN26789@aiede.mtv.corp.google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=sanchez.nevada@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).