Installing git on Windows 10, unable to access .gitconfig - windows

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.

Related

Unable to use git in WSL. C:\Windows\System32\OpenSSH\ssh.exe: not found

So im on Windows 10 and a while ago i decided to use WSL so the I can get zsh. However, now I can no long use git from my wsl terminal, i.e I can no longer git pull from remote repo. When I try I get the following...
'C:\Windows\System32\OpenSSH\ssh.exe': 1: C:\Windows\System32\OpenSSH\ssh.exe: not found
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Such operations work fine in bash and from GitHub Desktop. Why is WSL trying to use OpenSSH from Windows it should be Linux right?
Im struggling to find information on this problem so any help is greatly appreciated. Let me know if there is more information I can provide.
I got the same error after changing the value "core.sshCommand" like this:
git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"
In my file ~/.gitconfig, I disabled newlines like below :
#[core]
# sshCommand = 'C:\\Windows\\System32\\OpenSSH\\ssh.exe'
Then when you are in a git repository, if you have the same problem check your my-project/.git/config file and if there is the new config disable it as above.
In my case it worked :-)
Have a nice day
Double check if you have an environment variable GIT_SSH which would point to C:\Windows\System32\OpenSSH\ssh.exe: that would not be a valid path in a WSL session.
Unset it.
After that, it depends on the Windows 10 used ( 1709? 1809? 20H1? ...), and on the WSL used (WSL1 or WSL2?).

Can't configure git, missing .gitconfig file

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.

What are the necessary settings for "git configuration"?

when I create a project in Xcode 4.3 it keeps on displaying message saying below.I did not get what that means and how to do the necessary settings.
Any help will be greatly appreciated.
Thanks
Baha
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 say the identity only in
this repository.
fatal:unable to auto-detect email address
(got 'Home#s-imac-3.(none)")`
It's telling you literally, exactly what to do. Open a Terminal session, and run this, replacing 'you#example.com' with your email address:
git config --global user.email "you#example.com"
This sets your email address for git, it uses this to identify who you are in commits.
Then, run this, replacing 'Your Name' with your name:
git config --global user.name "Your Name"
This sets your name for git commit messages, it uses this to give a more readable name to commits.
If this stuff is not clear to you, you really owe it to yourself to learn git: http://try.github.io
Set Name & Email in Xcode preference, this issue will be resolve
Follow these 4 simple steps
Xcode => Preferences => Source control => Git
Set ( Author Name ) & ( Author Email ), just for identify that the code committed by this name/email
close Xcode and re-open project
now try to commit code, it should be working fine now.
Could be a issue with Xcode. Go to your git directory and set the user locally. See the following help thread at Apple Forum for more info:
https://forums.developer.apple.com/thread/18189
I had same issue in xCode 8.3.2, when I tried to create git repository on local machine. And I fixed it by setting local repository name and email. If anyone is having same issue; just run these commands in terminal:
cd my/project/directory (Navigate to project directory)
git config --local user.email "me#me.com"
git config --local user.name "myname"
NOTE: This is for local repository, and "--global" flah can be used for remote repositories.

How to change the path where Git creates ssh file while "remote add origin ..."?

Good times!
Please, hint me this moment - I use the Windows account with cyrillic account-name. When I try to add my local git repository to github.com, I get the mistake "Could not create directory c/Users/\204\206" ... and I suspect due to my account is cyrillic.
So - how to change this behavior? I want to use Git without changing or renaming account?
Git doesn't create any directories when you add a remote repository. That is, if you type a command like this:
git remote add origin git#github.com:you/yourproject.git
The only thing that happens is that git adds a couple of lines to the .git/config file.

Cannot get git extensions to push something to github SSH problems

Im trying to use git extensions and I really like it so far, but I don't manage to push to github. The following command works fine in git bash:
git push "origin" master:master
and then when I push with git extensions I get this:
C:\Program Files\Git\bin\git.exe push "origin" master:master
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Done
In the git settings it just has openSSH selected which I would like to keep because putty seems more hassle.
The remote addres I have added in gitextensions, actually the only thing I have done from the bash just to test is the command above and gerenating the SSH keys. All else is set up in git extensions. So I suppose everything must be set up correctly. Eg, the email adress and name are correct...
ssh git#github.com
also connects fine, from bash
edit:
So I can reproduce the error by putting the command from git-extensions in cmd. Appearantly there is a difference between running from git bash and from cmd and git-extensions runs this command like a windows command... any clues?
update:
If I choose git-bash from the menu in git-extensions I get a window that is exactly the same as when I right click in explorer on my repo folder and choose git bash here. Now, in the one opened from explorer I can push and in the one opened from extensions I get the public key problem.
Things to check for:
Presence of HOME environment variable.
Presence of %HOME%\.ssh\ and RSA keys there.
When you run git from command promt it is preferred to run git.cmd, because it fixes HOME automatically:
#if not exist "%HOME%" #set HOME=%HOMEDRIVE%%HOMEPATH%
#if not exist "%HOME%" #set HOME=%USERPROFILE%
To fix gitextensions, define HOME variable and set it to same value as USERPROFILE
Ok, I solved it.
I opened the git bash from git extensions and a git bash using the explorer shell extensions. I then ran ssh -vvv git#github.com from both to see the difference.
It turned out that because I changed the location of the git config file ( I tend to reformat every now and then, so c:\documents and settings... is notoriously bad for storing anything I might want to keep persistent), when run from git extensions git was also looking for the ssh keys in a different location. So I added the .ssh folder where my git cofig file is and now it works fine. I think git-extensions sets the HOME variable for git to whatever you set as path for the config file.
Now, that was not obvious...
The correct answer is the one from 'max' (set your HOME env var manually), but it may help some to understand why the problem is happening (as Git gets more users around the world it's going to be very common).
Cygwin sets $HOME to /home/yourname, but that variable is not known in the Windows environment. So if you open a bash window and do env | grep HOME you'll see all three 'HOME' variables mentioned here, and you might wonder why Gitextensions doesn't use your proper cygwin HOME - which is because its .bat file invocation doesn't see it - it only sees what you see from doing 'set' in a windows console.
It's mystifying why it doesn't do this evaluation later and get the proper cygwin path since it knows how to invoke bash, but (at least in versions up to 2.41) you have to do this manual change in the settings or in .gitconfig.
When you fire up git bash directly you'll land in your home folder for MSYS. You need to make sure you have your ssh key (id_rsa ?) in the .ssh subfolder (relative to the home folder).
Glad you solved the problem. Since this sounds like a serious problem I'm interested in the difference between git-bash when started from GitExtensions. In GitExtensions there is a setting that might fix this. The %HOME% directory can be changed in GitExtensios. By default it will be set to %HOMEDRIVE%%HOMEPATH%, but you can override this. Changing this probably solves your problem, since you suggest this is the problem. To change this open the settings dialog and go to the tab "git". In the section "Environment" you can set the %HOME% path.
I will appreciate it if you let me know if this also solves the problem. I'm also interested in what caused this in the first place. Maybe I can improve the check for a valid HOME directory.
Yes, not setting the HOME varible was the issue for me too.
Set the HOME variable as %USERPROFILE% and regenerate the Private and Public keys, then try cloning—it should work now.
I see that the HOME variable is set to USERPROFILE in git extensions. I can add and commit but not push/pull from the remote repository. I am unable to connect to any remote repository. We use http (not ssh) for the connection. However, using git bash I am able to connect to the remote and do push/pull. I had put my issue GIT extensions does not connect to remote but git bash does and was directed to this issue. However, I am unable to resolve my issue. Any ideas?

Resources