Does veracrypt do any sort of file caching in memory that might be preventing changes to my git config files to be recognized?
Long version: I have a repo on a veracrypt partition shared with Windows. While trying to enforce EOL's in my repo, I am seeing files more or less arbitrarily setting EOL's. When making a trivial change to my .gitattributes file, I'll merge this change onto a branch, and suddenly my new branch is filled with files with EOL-only changes.
I'm working on linux using mostly SmartGit or the cmd-line (git v 1.8.3.1). I've tried removed autocrlf and safecrlf or setting to false in both my global and repo config files in case they were confusing things. I've tried deleting my .gitattributes file, or setting
* binary
To prevent any conversion at all.
I have reset dozens of times, and deleted my local repo and re-cloned. But I cannot get rid of these modified files
git rm --cached -r .
git reset --hard
Below is my .gitattributes
# Auto detect text files and perform LF normalization
* text=auto
# Specify LF file endings for coding files
*.txt text eol=lf
*.c text eol=lf
*.cpp text eol=lf
*.h text eol=lf
*.py text eol=lf
*.kl text eol=lf
*.json text eol=lf
# Specify windows-only CRLF endings
*.bat text eol=crlf
*.vcproj text eol=crlf
*.sln text eol=crlf
# Specify binary files - do not modify these files, dammit!
*.so binary
*.dll binary
*.lib binary
*.pdb binary
*.exp binary
*.exe binary
My major problem is that some (not all) .so symlinks are showing up modified in one particular branch - looking for all the world like they've been converted. This consistently occurs in my latest branch, but not earlier branch. In the current spate of madness, my last merge added the *.cpp tag, which promptly converted some (not all) of my *.py files to windows line endings.
Has anyone experienced this kind of unreliability? Is the .gitattributes file supported in this version of git? Is veracrypt or the NTFS partition somehow confusing things on me?
I've been working on what should be a trivial task for a week now, and simply cannot fathom how git is deciding on its EOL strategy.
I still don't know precisely what is going wrong, but I recreated the repo, and as long as I never touch (use it read-only) it in windows it seems ok.
Related
I want to take advantage of gitlab image diff during merge request. However, instead of the image being rendered or the diff, this is what I'm getting:
A message saying: This diff was suppressed by a .gitattributes entry.
This is the .gitattributes file that we have setup, I don't understand how this is avoiding the image to show properly:
* text=auto
*.* text eol=lf
/.idea/* text eol=crlf
*.png binary
*.jpg binary
*.ico binary
*.pdf binary
If I remove the entry for PNG, then it is treated as text and the checked out images are not valid. What is the way to flag png as normal image files? What is the default? This seems to work if there is no .gitattributes file at all, so what is the proper one?
Thanks in advance
You could add the diff attribute to the .gitattributes file.
*.png binary diff
The behavior is slightly different. The diff is not collapsed by default. But it's ok I think.
We have a few work flows where we want to use git repositories mounted on NFS network shares. This generally works well, with the exception of line endings. Obviously, line endings on Linux and Windows differ, so a git status on the CentOS host may show no changes, and a git status in the same directory on Windows shows all files as modified.
Can any of the various git mechanisms to deal with line endings be configured to support this scenario ? We only want Unix-style line endings in our repos, of course, and we don't really care about the Windows SEEING the Unix line endings, but on occasion, a Windows tool will add or accidentally convert files, which we would then not want checked in with those endings.
There are a couple possible solutions here. The best solution depends on whether you care about the endings in the working tree.
If you always want line endings in the repository to be LF, and you don't care about the working tree, you can set the following in the .gitattributes file in your repository (creating it if it doesn't exist):
* text=auto
That will make Git guess whether a given file is binary or text, and if it's text, it will perform conversion to the proper line endings when it's checked out. On Unix, the proper line endings will be LF, and on Windows, usually it will be CRLF (although you can use core.eol to override that).
If you always want line endings in both the objects and the working tree to be LF, then you need to do a little more work. You need to set each individual text file type appropriately with eol=lf:
*.c text eol=lf
*.h text eol=lf
The reason this is necessary is because eol=lf overrides text detection, which means it's not safe to apply to binary files, such as PDFs or JPEG files. If you applied it to all files in your repository, you'd corrupt any binary files that happened to contain a CRLF.
Regardless of which you do, you should do a git add --renormalize . and then a git commit. That will ensure that all of your files in the repository contain LF endings and they'll be checked out with the appropriate endings whenever Git checks them out. That doesn't prevent Windows tools from dirtying the repository with CRLF line endings, but if they do that by accident, only LF endings will be checked in.
Im using a windows system to push my changes to a git linux server, where users commit with macOS, could this be the problem of invalid diff changes? changes which are not changes are displayed as deleted and later on re-added as new somehow. im using sublime and also tryed netbeans with the same behaviour...
Windows and *nix based operating system use different line ending character in files. In your case you are adding the Windows Carriage return character in your file and on MacOSX they are removed.
On your Sublime you can change the line ending character on save to match the MacOSX's line ending . See is there a way to convert files line ending on saving. This way you will not see these changes.
You could also instruct git to automatically do the conversion with the core.autocrlf config. See GitHub dealing with line endings
GitHub suggests that you should make sure to only use \n as a newline character in git-handled repos. There's an option to auto-convert:
$ git config --global core.autocrlf true
Of course, this is said to convert crlf to lf, while you want to convert cr to lf. I hope this still works …
And then convert your files:
# Remove everything from the index
$ git rm --cached -r .
# Re-add all the deleted files to the index
# You should get lots of messages like: "warning: CRLF will be replaced by LF in <file>."
$ git diff --cached --name-only -z | xargs -0 git add
# Commit
$ git commit -m "Fix CRLF"
As Per Git Config Manual
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.
The remote repo has mixed cr/lf lineendings, thought it was unix, now i just set the original lineending if it happens again.
I'm trying to do something very simple: check out a repo that has CRLF endings (and no .gitattributes) file, and end up with native (LF) line endings. I don't even want to commit back.
I've read Github's suggestion, and Tim Clem's article, but mostly they seem aimed at Windows developers.
I've tried this:
$ git config --global core.autocrlf=input
$ git clone https://github.com/DennisSchiefer/Project-OSRM-Web.git
But no - the file I care about, OSRM.Config.js, still has CRLF endings.
Trying core.autocrlf=true didn't help.
Even adding and committing a .gitattributes file (then git rm --cached -r . && git reset --hard) doesn't help.
I can't find any combination that will actually leave LF line endings on this file.
core.autocrlf will force git to process all text files.
If OSRM.Config.js is not processed, that means Git deems it binary.
See:
"How to determine if Git handles a file as binary or as text?"
"Why does Git treat this text file as a binary file?"
Even with a .gitattributes with *.js text, that would still keep crlf.
But with *.js eol=lf, that would actually force the conversion.
See "Can git's .gitattributes treat all files as binary except a few exceptions?".
I tried to pull some changes while I had some files opened in vim, and while committing and merging and the sort, ended up coming up with:
alex#adebian:~/cs4290/p3$ hg status
R test
! project3_framework/protocols/.MI_protocol.cpp.swp
! project3_framework/protocols/.MSI_protocol.cpp.swp
I added a .hgignore file in my project with the following:
syntax: glob
*.cpp.swp
I've since closed my vim session (removing the files) yet the files keep showing up. How do I get mercurail to ignore the .swp files?
! sign means that mercurial cannot find the file that has been already added to the repository. So you need to forget or remove those files at first. After that - they will not appear anymore in the status since you have ignored them.
I agree with zerkms... forget or remove those files to get rid of the !. Also, as you've probably noticed, simply creating a .hgignore file with some content does not go through the repository and remove matching files. If you've added foo.c to your project and then you create the following .hgignore:
syntax: glob
*.c
foo.c will still be a part of the project - you would need to remove it explicitly.
You can use
set directory=c:\\workfiles\\
in your .vimrc to write swap files in a "special" folder