Created
April 4, 2012 17:40
-
-
Save gabetax/2304167 to your computer and use it in GitHub Desktop.
git autocrlf input example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gabebug@Gabe-Work ~/Sites $ git init crlf | |
Initialized empty Git repository in /Users/gabebug/Sites/crlf/.git/ | |
gabebug@Gabe-Work ~/Sites $ cd crlf/ | |
gabebug@Gabe-Work ~/Sites/crlf $ git config core.autocrlf | |
input | |
gabebug@Gabe-Work ~/Sites/crlf $ vim crlf.txt | |
gabebug@Gabe-Work ~/Sites/crlf $ xxd crlf.txt | |
0000000: 610d 0a62 0d0a 630d 0a a..b..c.. | |
gabebug@Gabe-Work ~/Sites/crlf $ git add crlf.txt | |
warning: CRLF will be replaced by LF in crlf.txt. | |
The file will have its original line endings in your working directory. | |
gabebug@Gabe-Work ~/Sites/crlf $ git ci -m "add crlf" | |
[master (root-commit) 77861ec] add crlf | |
warning: CRLF will be replaced by LF in crlf.txt. | |
The file will have its original line endings in your working directory. | |
1 files changed, 3 insertions(+), 0 deletions(-) | |
create mode 100644 crlf.txt | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ xxd crlf.txt | |
0000000: 610d 0a62 0d0a 630d 0a a..b..c.. | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ git co crlf.txt | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ xxd crlf.txt | |
0000000: 610d 0a62 0d0a 630d 0a a..b..c.. | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ rm crlf.txt | |
gabebug@Gabe-Work ~/Sites/crlf[master*] $ git co crlf.txt | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ xxd crlf.txt | |
0000000: 610a 620a 630a a.b.c. | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ perl -pi -e 's/\n/\r\n/g' crlf.txt | |
gabebug@Gabe-Work ~/Sites/crlf[master*] $ xxd crlf.txt | |
0000000: 610d 0a62 0d0a 630d 0a a..b..c.. | |
gabebug@Gabe-Work ~/Sites/crlf[master*] $ git st | |
# On branch master | |
# Changes not staged for commit: | |
# (use "git add <file>..." to update what will be committed) | |
# (use "git checkout -- <file>..." to discard changes in working directory) | |
# | |
# modified: crlf.txt | |
# | |
no changes added to commit (use "git add" and/or "git commit -a") | |
gabebug@Gabe-Work ~/Sites/crlf[master*] $ git add crlf.txt | |
warning: CRLF will be replaced by LF in crlf.txt. | |
The file will have its original line endings in your working directory. | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ git st | |
# On branch master | |
nothing to commit (working directory clean) | |
gabebug@Gabe-Work ~/Sites/crlf[master] $ xxd crlf.txt | |
0000000: 610d 0a62 0d0a 630d 0a a..b..c.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A few conclusions about
autocrlf=input
git add
on a file with only CRLF -> LF or LF -> CRLF changes cause the file to no longer show as modified and will not appear on the stageIf you're in a scenario where you have rsync an export (with changes) of the repository on to your repository to commit them, and the export has CRLFs in it, just running a
git add
on every file will make your change list ignore the CRLFs. An easy way to do this for pre-existing files is: