git compatibilty setting on windows for using linux server over windows share - linux

I've installed the latest version from git-scm.com on my Windows 8.1 System. My Dev Server is a Linux Server, but I'm connected to this server using a windows share.
After the git initalization, I've started to "add" files to the repositiory and received this message on the windows command line, for every file:
warning: LF will be replaced by CRLF in inc/src/tpl/default.smarty.
The file will have its original line endings in your working
directory.
While installing git I selected option 1 from this options:
Checkout Windows-style, commit Unix-style line endings
Checkout as-is, commit Unix-style line endings
Checkout as-is, commit as-is
So I'm working on windows, commiting over a windows share to a linux server, and I will also push these changes to another linux server.
Now I'm a little bit unsure about this setting because I'm working on a linux server. The only windows "Thing" is my command line and that I'm editing the files using a windows share.
I would like to know, if this is the right setting for git, or if I'm doing it wrong.
Thanks

I'm not 100% clear on your setup, but here is what is happening. The files you are adding have Unix-style line endings (i.e. they end with LF). Since you picked option 1, git is just warning you that when you check these files out on your Windows box, they will have Windows-style line endings (i.e. they will end with CRLF).
Normally this is nothing to worry about, but you mention that you "will also push these changes to another linux server." If by this you mean a git push, then no worries; the line endings will be normalized to Unix-style in the repository. However, if you mean that you copy the files from your Windows box to a Linux box, then you will eventually end up copying files with Windows-style line endings to the Linux box, which you probably don't want to do. If that is the case, you are probably better off with option 3. Note that if you edit these files on your Windows box, you may even want to go option 2, so that you will always have Unix-style line endings in the repository.

Related

There are some changes opening in the linux of a git repo. But the repo is latest in windows

My pc is a dual system with Linux Mint and Windows 11.
The git repo always has some changes in Linux.
Every time I need to git stash and git stash drop.
I don't know how to descript this situation with google.
Help pls. Thanks.
The problem is that you have different line ending settings between Linux and Windows. What you're seeing in Linux is that your files have carriage returns on the end of them, which is the Windows line ending.
The easiest way to solve this is to add this to .gitattributes:
* text=auto
Then, on an otherwise empty working tree, add that file, run git add --renormalize ., and commit. That will cause the files to be renormalized as having LF line endings in the index.
If you're going to be working across OSes, then you'd also do well to add eol=lf to the end of that line in .gitattributes so that files are always handled with LF endings. You'll also need to configure your tools on Windows to emit LF endings instead of CRLF endings. That will prevent line ending differences in the working tree across systems.

CRLF tags attached upon FTP upload from a windows to Linux Server

I am uploading the files in a FTP folder from Windows server to a Linux server. Files come in different extensions but can be opened using notepad or notpad++.
I am getting issues that CR & CRLF are getting attached after FTP upload to Linux from Windows.
I am uploading a file from windows in the below format
This is the file after FTP Upload to Linux server. We can see many CR and CRLF tags getting attached, which shouldn't be the case.
I need the files in the below format in Linux (With only LF tags attached)
For FTP from windows to Linux, I am using the Batch Script as below..
open XXXXXXXXXX.net
UID
PASSWORD
cd METS
cd MARVELRAIL
binary
mput E:\METS+_BULK_UPLOAD\BULK_FOLDERS\OUT\DISCH\*.*
quit
Can you help me where I am going wrong and how to beat this issue...
Thank in advance.
If you want the files to be converted to *nix line endings, do not use a binary mode, use an ascii mode.
The ascii mode is the default one, so removing binary command should be enough.
Or you can explicitly use ascii command.

Git line endings in multi OS environment

I installed Linux Mint on PC and then I cloned git repository from Bitbucket to work on it. After some changes I did commit in my PhpStorm ide. During this commit git fired me a dialog about line endings. There were two options. If I remember
create gitattribute file which handles line endings for project
set global handler for line endings via command like core.autocrlf true
I selected global option but as I see it made all the project files changed. Now I am not sure what happens and if I can push it to server. What happens if somebody pulls it on Windows? Will make a merge? How to solve it?
As per the git-config Documentation:
core.autocrlf
Setting this variable to "true" is almost the same as setting the text attribute to "auto" on all files except that text files are not guaranteed to be normalized: files that contain CRLF in the repository will not be touched. Use this setting if you want to have CRLF line endings in your working directory even though the repository does not have normalized line endings. This variable can be set to input, in which case no output conversion is performed.
Having core.autocrlf set to true means that git will conditionally convert line endings to CRLF in your working directory and to LF in your repository.
Please see: What's the best CRLF (carriage return, line feed) handling strategy with Git?

Git/Jenkins/Windows (not ordered) line ending issue

I'm playing with a Qt project in Windows. Actually I'm preparing it to build on Linux also. The problem is that the build.sh script (below) inflates 1 byte per line (*) somewhere in the process which makes it fail when it gets executed by the end user.
*I'm comparing the size in the developer machine against the size in the end user machine. Between these, Jenkins (running on Windows) get things from git server and packs a tar.gz file (using cygwin), which the end user gets after all.
#!/bin/bash
qmake Project.pro
make
make clean
How should I approach this issue?
May I provide more information?
To me it looks like git Jenkins is using on Windows has crlf conversion enabled - it will take Linux line endings \n and convert them to \n\r. The symptom you usually see is
/bin/bash^M: bad interpreter: No such file or directory
You should probably set core.autocrlf = input, or at least prevent automatic conversion on script, binary, archives, etc...
See here for more details: https://help.github.com/articles/dealing-with-line-endings/#platform-all. I know it suggests using core.autocrlf = true for Windows, but you are actually using Cygwin on Windows, and you are packing scripts for Cygwin so you probably want core.autocrlf = input (no conversion).

Git problems with line endings differences between linux and windows

I'm working on a project on Windows and some project files seems to be changed locally but I didn't. Was ignoring them but now I cannot push because are unstaged files. When I look into this files differences, there isn't, only this line ending thing (CRLF, LF).
Tried to revert this files, reset --hard too.
Why can't I reset this files to repository HEAD?
Tried to do this too:
git config --global core.autocrlf false
If I do git reset --hard and git status later I get message that have many files with changes not staged.
Sorry but I don't know git and this linux/windows line ending differences very well.
Maybe someone else working on the project introduced bad line endings. two things 2 do:
fix bad line endings already committed.
align the team about the line endings policy.
See: Dealing with line endings.

Resources