git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Walter Bright <boost@digitalmars.com>
Cc: git@vger.kernel.org
Subject: Re: noob user, want checkins to all be forced to LF terminated lines
Date: Fri, 30 Jul 2010 23:49:57 -0500	[thread overview]
Message-ID: <20100731044957.GA8920@burratino> (raw)
In-Reply-To: <i308gl$v6p$1@dough.gmane.org>

Walter Bright wrote:

> I've just started with git.

I thought I saw you here years ago. :)

> Exactly what do I put in $HOME/.gitconfig ?

Well, naturally it depends on what you want to happen.

If you just want to make sure any new files you commit are tracked
with simple LF line endings, you can use

	[core]
		autocrlf = input

With this setting, Git will not do any munging to files in the work
tree in any way (unless there is a .gitattributes file requesting to
do so).

That is an _altruistic_ setting to use.  It ensures you do not pollute
history with some alternative line-ending, but your own work tree may
not necessarily match the cleaned up versions you are checking in; so
if you try to "git add" and then "touch" a file with CRLF line endings
with this setting enabled, you may be surprised at the result!
(Though a simple "git checkout file.c" afterwards should fix up the
line endings in the work tree.)

If you want to make sure text files in the work tree use LF line
endings and you are using a recent version of Git, use the above
setting or

	[core]
		eol = lf

On Unix-y systems, you do not have to do that, since it is the
default.  On Windows, the "[core] autocrlf" setting is set up
by default in /etc/gitconfig so you would probably want to
override that with

	[core]
		autocrlf = false

if you are not setting it to input.

Which files are text files? you may ask.  By default (unless
autocrlf is enabled), Git treats files as raw data; to get it
to futz with line endings, you have to declare your text files
in a file named .gitattributes in the tracked tree.

	* crlf
	*.jpg -crlf
	*.png -crlf

The keyword crlf here means “apply line-ending conversions” and
nothing more.  In particular, it does not represent the preferred
line ending.

If everyone for which you want these setting to take effect uses a
recent version of git, you can write “text” instead of “crlf” if
you prefer.

Hope that helps,
Jonathan

  reply	other threads:[~2010-07-31  4:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-31  4:23 noob user, want checkins to all be forced to LF terminated lines Walter Bright
2010-07-31  4:49 ` Jonathan Nieder [this message]
2010-07-31  5:14   ` Walter Bright
2010-07-31  5:39     ` Ilari Liusvaara
2010-07-31  5:45       ` Walter Bright
2010-07-31  5:57         ` Ilari Liusvaara
2010-07-31  6:24           ` Walter Bright
2010-07-31 15:12             ` David Aguilar
2010-07-31  5:44     ` Jonathan Nieder
2010-07-31  6:32       ` Walter Bright
2010-07-31  6:41         ` Ilari Liusvaara
2010-07-31 20:38         ` Jonathan Nieder
2010-07-31 20:51           ` Walter Bright
2010-08-03 23:56         ` Jay Soffian
2010-08-04  5:29           ` Will Palmer
2010-07-31  5:41 ` Miles Bader

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100731044957.GA8920@burratino \
    --to=jrnieder@gmail.com \
    --cc=boost@digitalmars.com \
    --cc=git@vger.kernel.org \
    /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.
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 NNTP newsgroup(s).