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

Re: Git Config Question

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 19, 2010, 05:59 UTC
Message-ID
<20100719055909.GA16276@burratino>
In-Reply-To
<AANLkTin8tW_qiRO57F-yjYHzhUkrZbO1g3L_hmesenGL@mail.gmail.com>
(+cc: Eyvind Bernhardsen, Finn Arne Gangstad)
Hi!
Shilpa Kulkarni wrote:
Show 7 quoted lines
> 2. Person Y checks in code (commit & push). Checks in file a, b.
>
> 3. Person X does a 'git pull origin master'.
>
> Pull succeeds - however
> 'git status' shows file a, b as modified even though person X has done
> nothing with these files.
[...]
Show 5 quoted lines
> Someone has recommended we all use
> core.safecrlf=false
> core.autocrlf=false
> But this would require running dos2unix cmd while running scripts on
> linux which seems like an overhead.

I have not kept up with the latest best practices. But I suspect something like the following would work:

1. In .git/config, ~/.gitconfig, or /etc/gitconfig, on Windows:
	[core]
		autocrlf = true

See core.autocrlf in git-config(1). I think git for windows does this automatically.

2. In .git/config, ~/.gitconfig, or /etc/gitconfig, on Unix:
	[core]
		autocrlf = input
3. Convert line-endings in the tracked content.  Something like:
	$ git status; # make sure there are no untracked files present
	$ git rm -fr --cached .; # stop tracking all files
	$ git add .; # fix line-endings on all files
	$ git commit; # record that you have done so
4. Convert line-endings in the work tree.  Something like:
	$ git rm -fr .; # remove all tracked files
	$ git checkout HEAD -- .; # fetch them back again
5. In .gitattributes, something like:
	*	auto
	*.sh	crlf
	*.[ch]	crlf
	*.jpg	-crlf
See gitattributes(5) for details.

Hope that helps, Jonathan

Previous: Shilpa KulkarniNext: Eyvind Bernhardsen
Message 2 of 3 in “Git Config Question”
  1. Shilpa KulkarniJul 19, 2010
  2. Jonathan NiederJul 19, 2010
  3. Eyvind BernhardsenAug 2, 2010

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.