when I try to config Git I receive the following error:
$ git config --global user.name "John Smith"
error: could not lock config file /Users/John/.gitconfig: No such file or directory
My root directory is completely missing a .gitconfig file. When I try to make a new one I receive this error:
$ touch ~/.gitconfig
touch: /Users/John/.gitconfig: No such file or directory
My git's location:
$ which git
/usr/local/git/bin/git
I've tried reinstalling Git several times (running OSX Yosemite) and I'm still having the same issue. I also cannot locate any .gitconfig.lock files, as mentioned in some posts regarding this issue.
So I ended up solving this issue by reading the Customizing Git section of the documentation.
While I could not touch a new .gitconfig file in my root directory as stated above, I read that the first place Git looks for configuration values is in etc/gitconfig (note the lack of a . in the name).
So I created a file called gitconfig inside of the etc directory and filled it in with a sample gitconfig I found online, and added my user information to the top like so:
[user]
name = John Smith
email = jsmith#example.com
I was then able to commit as my usual self, however I still don't have a .gitconfig in my root, so I am unable to config Git using git config --global, and must do the configurations manually in etc/gitconfig.
For me the .gitconfig file was missing.I tried reinstalling Git several times, however it din't help me. I resolved the issue by performing the below steps.
create a folder structure c:/dev/home if already not present.
Open the Windows command prompt. (Run as administrator)
From the Windows command prompt, run the command "git init"
Run the following command:
git config --global user.name "Example"
Run the following command:
git config --global user.email "Example#gmail.com"
The above steps will create the .gitconfig file in the path c:/dev/home and you will be able to set your desired username and email id.
On Windows systems, Git looks for the .gitconfig file in the $HOME directory (C:\Users\$USER for most people). So copy the file created in the above step to your Home directory by providing the required permission.
I solved that. By adding .gitconfig file to the Home directory. Now it works fine.
Related
I'm new to Git and Github and I'm just trying to set up my desktop client to be able to upload my projects.
When trying to commit I get this error from the desktop client:
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you#example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'wsm1u#DESKTOP-5ICE6RR.(none)')
So then I use Windows Powershell and get this error:
PS C:\WINDOWS\system32> cd $HOME
PS C:\Users\wsm1u> git config --global user.email "wsm1usa1va1b#gmail.com"
>>
error: could not lock config file C:/desktop/.gitconfig: No such file or directory
Basically, I think the problem is that Git is searching for the config file in the wrong place, but I'm not sure how to have it search elsewhere.
Here are the solutions I've tried:
uninstalling and reinstalling Git
running Windows Powershell as admin (this gives back the same error message)
Pasting a copy of .gitconfig in my desktop (this didn't work so I deleted it)
running git lfs install --force to reset Git configuration, this gave the error message warning: error running C:\Program Files\Git\mingw64\libexec\git-core\git.exe 'config' '--includes' '--global' '--replace-all' 'filter.lfs.clean' 'git-lfs clean -- %f': 'error: could not lock config file C:/desktop/.gitconfig: No such file or directory' 'exit status 255' Run "git lfs install --force" to reset Git configuration.
Tried to locate a .gitconfig.lock file as per this solution: https://askubuntu.com/questions/258288/trouble-setting-up-git-error-could-not-lock-config-file
Here is my system info: System information
Thank you for your help! :)
TL;DR
I set my HOME
Found some gitconfig files in my trash and deleted them
I was able to set name and email through cmd as admin.
I was able to commit!
Long version
I ran cmd: set HOME and got
C:\Users\wsm1u>set HOME HOME=C:\desktop HOMEDRIVE=C: HOMEPATH=\Users\wsm1u
I went to: https://superuser.com/questions/246731/how-do-i-change-homedrive-homepath-and-homeshare-in-windows-xp ⇒ Marc B's solution (setting home path through "advanced system settings")
Committed through GitHub desktop -> got "tell me who you are" error
Set email in cmd -> got blank return
Set name -> got "permission denied" error
Ran cmd as admin
Set name -> got blank return
Tried to commit again and "Please tell me who you are" error again.
Ran git.bash as admin and set name/email then ran git config ‒list and got correct name and email returned
Tried to commit and got "please tell me who you are" error again
I tried creating a copy of my github desktop client in the program files directory because that is where my git directory is located. I thought maybe the client would only be able to find it that way (this made sense in my head) and that didn't work, so I deleted it.
While I was in progam files though I noticed that there was a .gitconfig there and so I deleted that, then I emptied my trash and noticed there were more in there.
Then I ran git config ‒list again and the name and email were gone from the return
Then I set name and email again in cmd as admin and I WAS ABLE TO COMMIT FOR THE FIRST TIME!!!
Git version: 2.13.0.windows.1
OS: Windows 7
CLI: Git bash
.gitconfig
[user]
name = Gyandeep Singh
email = private#email.com
[push]
default = current
[core]
autocrlf = input
[includeIf "gitdir: ~/Documents/webstorm/corporate/"]
path = .gitconfig-work
.gitconfig-work
[user]
name = Gyandeep Singh
email = corporate#email.com
Both the config files above sit together in the same directory (home).
What happened: open CLI on a folder (example test) inside corporate folder and then run git config user.email the output is private#email.com.
Expected: Outcome should be corporate#email.com.
Am I doing something wrong or my expectation is not correct? I did follow the git docs.
Solution
You have to run git config --show-origin --get user.email on a git initialized directory. If its not git initialized then the includeIf gitdir functionality will not work.
Its strange but true. I wish it still worked.
Your global C:/Users/<user-name>/.gitconfig should have this includeIf:
[includeIf "gitdir:C:/Users/<user-name>/Documents/webstorm/corporate/"]
path = .gitconfig-work
with having your work Git repos in C:/Users/<user-name>/Documents/webstorm/corporate and the conditional work configuration should be located at C:/Users/<user-name>/.gitconfig-work.
That's at least working for me in Window's cmd and Cmder. A git config --show-origin --get user.email should than show you from where a config value is loaded/resolved.
It also seems like the conditional work configuration is only used when issued from within a Git repository.
C:\Users\<user-name>\Documents\webstorm\corporate
λ git config --show-origin --get user.email
file:C:/Users/<user-name>/.gitconfig foo#oss.com
C:\Users\<user-name>\Documents\webstorm\corporate\some-repo
λ git config --show-origin --get user.email
file:C:/Users/<user-name>/.gitconfig-work foo#company.com
C:\Users\<user-name>\Documents\webstorm\corporate\some-non-repo-dir
λ git config --show-origin --get user.email
file:C:/Users/<user-name>/.gitconfig foo#oss.com
You need to turn off case sensitivity: change "gitdir:" to "gitdir/i:"
[includeIf "gitdir/i:C:/Work/"]
path = .gitconfig-work
[includeIf "gitdir/i:C:/My/Dev/"]
path = .gitconfig-my
from:
https://github.com/Microsoft/vscode/issues/62921#issuecomment-437693020
The accepted answer, while helpful, does not answer the question.
As of this writing, includeIf only works inside a git initialized folder.
So if you cd into "~/Documents/webstorm/corporate/somegitproject" and run the command the output will be as expected:
$ cd ~/Documents/webstorm/corporate/somegitproject
$ git config user.email
corporate#email.com
This is probably a defect against git, since a user would expect this to work similarly in "~/Documents/webstorm/corporate/" as well.
There is a typo here:
[includeIf "gitdir: ~/Documents/webstorm/corporate/"]
path = .gitconfig-work
There should be no space after gitdir::
[includeIf "gitdir:~/Documents/webstorm/corporate/"]
path = .gitconfig-work
Removing it will correct the behavior within an initialized Git repository.
This will show the entire Git configuration and what Git config files it is drawn from:
git config --list --show-origin
CAVEAT: If you run this inside a Git repository it will show values from .gitconfig-work, but it will not if you are within ~/Documents/webstorm/corporate/, but outside a Git repository.
The OP concludes that includeIf functionality does not work in normal non-git directories.
This is provably incorrect for at least the configuration item core.sshCommand. If a conditionally included .gitconfig has a core.sshCommand configured, it is used in git clone operations in normal non-git directories.
It seems that the part that doesn't work properly is the display of conditionally included configuration. Which is quite problematic and interferes with tracking down broken configurations.
I mapped a directory to a drive on a windows machine with subst D: <mapped directory>. If you want to know the path of your repository you can use this command in the repository context:
git rev-parse --show-toplevel
The output was something like this:
<mapped directory>/<name of repository>
So I changed it to:
[includeIf "gitdir:<mapped directory>/"]
path = .gitconfig-work
Now it works for me.
I'm new to git, and i'm trying to install git 2.9.2 from here. In the installation (the last of the many) i chose to run it from bash only. I now try to set it up, and the first thing i try is to set my name with
$ git config --global user.name "My Name"
But after i execute this, i get:
fatal: unable to access 'C:\Program Files\Git\ C:\Windows\system32\config\systemprofile/.config/git/config': Invalid argument
Let's say that i now want to clone a repository. I insert something like:
git clone https://username#bitbucket.org/team/repo.git
But i get:
fatal: unable to access 'D:\TestRepo\ C:\Users\username/.config/git/config': Invalid argument
I thought that the .gitconfig file should be inside the C:/Users/username directory, but it tries to locate C:\Users\username/.config/git/config, which seems a little weird. My HOME variable is %USERPROFILE%, as it should. Any help appreciated.
Ok i guess my lack of knowledge over basic things made me look stupid...
I just had to delete the HOME environmental variable and all worked like charm. I don't even remember why i had a HOME variable set (isn't that a linux thing?)
Anyway thank you for your time guys.
Did you use git init on the folder you are trying to operate from?
Also you need to configure your username and the email to your github account for it to work properly.
git config --global user.name "username"
git config --global user.email "email#gmail.com"
Finally, if you have a space in your name please remember to escape it. ex: "my name" = "my\ name"
did you set up your remote repository?
git remote add origin https://github.com/rodoggx/yourRepository.git
Same issue. But if I run with command shell (not bash) with Admin level, git config --global -l works. My git version 2.25.0.windows.1
I noticed that in the System Info gui of Windows, the env variables for System had a HOME entry of %USERPROFILE%. But, the User env variables did not. I added HOME to that too.
Now it works. You'd think the System env would fill in for those not in User. Maybe something else is going on.
i am working with an other developer in developing an iOS application and now he don't work with us and i am working with his computer but the problem is when i push my code i am seeing his name appearing in the github. how i can change this and put my name appearing in the github. thanks for your answers.
Do you have a .gitconfig file in your project directory, if so, cd into the project directory and run the following commands to set it to your name and email in the .gitconfig file of your project
git config user.name "Your Name"
git config user.email "your-email-address#email.com"
If you do not have a .gitconfig file in your project directory, it could be using the global .gitconfig file located in the Home directory (~/). Simply add the --global flag to set it on a global basis for all projects (note, if there is a .gitconfig file within the project directory, it will use that rather than the global .gitconfig in the home directory)
git config --global user.name "Your name"
git config --global user.email "your-email-address#email.com"
I ran the following code to pull files from windows git repository.
git pull /Volumes/sucho/Desktop/git/setup
And I connect the Windows directory as follows.
tell application "Finder"
mount volume "cifs://WINDOWS/c$/Users/sucho" as user name "USR" with password "PW"
end tell
It works well, but the problem is the pulled files from windows have 700 (rwx------). How can I set it 644(rw-r--r--) as default?
This isn't really answering your original question, but I hope to highlight another issue I ran into when attempting to trying #drewag's proposed solution...
Another issue I ran into when attempting to ignore file permissions, regardless of whether it was on a Windows or Mac machine (more prevelant on the Windows machine!), was the problem global vs. project-level configurations.
Running this command did not affect the .gitconfig file in my C:\Users\Username folder:
git config core.filemode false
Although adding the --global flag did affect the change I was looking for:
git config --global core.filemode false
Hope this helps someone solve some of their headaches!
If you don't care about file permissions, you can just tell your repository to ignore file permission:
git config core.filemode false