I want to configure Git, but I deleted my configuration file before (a big mistake). It shows me
No such file or directory
when I put in ~/.gitconfig:
$ git config global user.name "a"
error: key does not contain a section: global
$ ~/.gitconfig
-bash:/.gitconfig: No such file or directory
Add dashes to global:
git config --global user.name "a"
Without the dashes global is getting interpreted as a section, but that's not valid. You want the --global flag.
The file doesn't need to exist before you run this command. Git will create it if it's not there.
Related
I have a repo that will only ever be used on Windows. And I would prefer that source control does not modify the contents of my files in any way.
I set core.autocrlf to false in global settings and verified that no local repo override was present. I found that there was an existing .gitattributes file in my repo with * text=auto as the only entry. So I deleted the .gitattributes file. From reading the documentation, my understanding is that this should result in text being unspecified, and will follow the behavior set for core.autocrlf.
However, I still get the following error when I stage my files:
LF will be replaced by CRLF in MyProject/src/static/images/logo.svg.
The file will have its original line endings in your working directory.
If I understand correctly, there's something that still modifies my files. What is it and how can I stop it?
First, as I mentioned in "Windows git “warning: LF will be replaced by CRLF”, is that warning tail backward?", make sure to:
use a recent Git for Windows (more than 2.19 at the very least)
set git config --global core.autocrlf false (you have done so, as specified in your question: good)
Since you don't have a .gitattributes file, there is no text attribute for svg files:
If the text attribute is unspecified, Git uses the core.autocrlf configuration variable to determine if the file should be converted.
Second, check if an add --renormalize would help
git add --renormalize .
git commit -m "Introduce end-of-line final normalization if needed"
git push
Then check if a new clone of the repository would still ehibit the same message.
Note: the warning message has changed with Git 2.37 (Q3 2022).
I'm on Win10 trying to git pull from a repository where a file named con.dat exists - it has been created and then checked into git on different OS obviously. I know why you can't have a file named con.dat on Windows, and I actually don't need that file. I just want the rest of the repository to pull and checkout the other files and not stop and fail when it can't create the con.dat.
The exact error is:
error: unable to stat just-written file Resources/CON.dat: No such file or directory
Use sparse checkout.
printf >.git/info/sparse-checkout %s\\n \
'*' '!'{con,prn,aux,nul,lpt[1-9],com[1-9]}{,'.*'}
git config core.sparsecheckout true
You might need to match the committed case, is it con or CON?
I use a combination of sparse checkout and the core.protectNTFS config option to allow Windows reserved filenames that are valid for NTFS (e.g. PRN).
https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreprotectNTFS
./git/config:
[core]
protectNTFS = false
I tried to remove the values (to reset them) but they won't go away. Plus they contradict each other.
C:\Users\Chloe\workspace\app>git config --unset-all core.autocrlf
C:\Users\Chloe\workspace\app>git config --unset-all core.editor
C:\Users\Chloe\workspace\app>git config --unset-all core.edit
C:\Users\Chloe\workspace\app>git config -l | grep autocrlf
core.autocrlf=true
core.autocrlf=false
C:\Users\Chloe\workspace\app>git config -l | grep notepad
core.editor=/C/Program Files/Notepad++/notepad++.exe
core.edit=C:\\Program Files\\Notepad++\\notepad++.exe
I tried to edit the values with git config -e (but first I had to figure out how to specify the path correctly), and it didn't list either of those config keys.
git version 2.16.3.windows.1
I found this answer http://stackoverflow.com/questions/2114111/ddg#2115116
And I used git config --list --show-origin then edited the files manually (from an elevated Notepad++). I had
file:"C:\\ProgramData/Git/config" core.autocrlf=true
file:C:/Users/Chloe/.gitconfig core.autocrlf=false
file:C:/Users/Chloe/.gitconfig core.editor=/C/Program Files/Notepad++/notepad++.exe
file:C:/Users/Chloe/.gitconfig core.edit=C:\\Program Files\\Notepad++\\notepad++.exe
Overall it was looking in 4 places: C:\ProgramData\Git\config, C:\Program Files\Git\mingw64\etc\gitconfig, C:/Users/Chloe/.gitconfig, .git/config.
Run git config -l --show-origin to see where from the settings come. Most probably from the global ~/.gitconfig so remove them with
git config --global --unset-all core.autocrlf
Using git svn fetch to do some local work (using git personally), I got a file that will not "reset". I see that it's different from similar files in the same directory in that it has a backslash as part of the name: icon#2xios8\.png. I suppose the backslash doesn't do anything on other platforms but msysgit on Windows 10 complains that it's unable to create the file.
I can't figure out how to make git ignore this subdirectory and let me continue with unrelated work. But I really need to fix it somehow so git can be used.
You can do this with git-read-tree and sparse checkout (git-read-tree).
Therefore you call
git config core.sparsecheckout true
Then create a file .git/info/sparse-checkout (with touch .git/info/sparse-checkout in msysgit bash). Edit this file and change its content to:
/*
!icon#2xios8\\.png
This tells git to look at all files in your working directory (/*) but '!icon#2xios8.png' (!icon#2xios8\\.png). Notice the escaped backslash here (\\)!
After you run git read-tree -mu HEAD you should be able to pull your repository by ignoring that specific file.
git, windows 7. I try set a text editor via different ways:
$ git config --global core.editor "C:\Program Files\Notepad++\notepad++.exe"
$ git config --global core.editor \"C:\Program Files\Notepad++\notepad++.exe\"
$ git config --global core.editor 'C:\Program Files\Notepad++\notepad++.exe'
But when I look the config file (via the git config --list command), I get the same result:
core.editor=C:\Program Files\Notepad++\notepad++.exe
So, I can't do a commit, I get an error:
$ git commit C:\Program Files\Notepad++\notepad++.exe: C:Program:
command not found error: There was a problem with the editor
'C:\Program Files\Notepad++\notepad++ .exe'. Please supply the message
using either -m or -F option.
I tried edit the .gitconfig file manually (I added the quotes) but it is not help me.
Why quotes are ignored and how can I solve it?
Try that
git config --global core.editor "'C:\Program Files\Notepad++\notepad++.exe'"
You should use forward slashes (/) rather than backslashes (\) in your pathname.
Source: [here] under "Configuring git and the helpers"