How to fix the git-upload-pack issue in Windows 10 Git - windows

There are several answer but I couldn't understand it to well.
I set up a bare repo in my desktop at C:/git/project1
my local ip is 192.168.0.2
when I tried to clone project1 in my laptop: Roi#192.168.0.2
git-upload-pack not recognized pops up.
is there a step-by-step procedure to fix this?
I'm new to git generally so I have little idea of the configs etc.

Assuming that ssh Roi#192.168.0.2 works (from your laptop, opening a shell session to your desktop), you need to make sure C:\path\to\Git\bin is in the system PATH of your desktop.
An alternative would be to defined a shared folder on your desktop (above your repo folder), and access it through \\192.168.0.2\shareFolder\myrepo from your laptop.
Then only Git on your laptop would be needed.

Related

IntelliJ IDEA git Permission denied (publickey)

I got a strange problem with using git on IntelliJ IDEA on Windows 10.
If I want to access the remote repo on GitLab, I always get
Permission denied (publickey).
Everything I found here or via Google didn't solve the problem.
I tried:
Setting the ssh executable to Native
Converting my public key from Putty to ssh-keygen style
Removing known_hosts
I also tried to access the repo with Git Bash, it works fine like that.
Another interesting fact is that after removing known_hosts, I got "Host key verification failed". I had to use Git Bash once to recreate the known_hosts entry, after that I got the Permission denied error again. Somehow I don't get asked for any user input.
I faced this problem while connecting bitbucket cloud from my Intellij 2019.2 , which thankfully got solved with the following steps. Please note that these steps are to be carried out after you successfully generate and add ssh-public key to your bitbucket/github/gitlab profile.
Open Git-SCM ssh_config file present in Git-SCM installation directory.It's default location in Windows (for 64 bit) is in C:\Program Files\Git\etc\ssh\
Add the following lines into ssh_config
Host *your-gitlab-or-github-or-bitbucket-hostname*
IdentityFile *your-ssh-rsa-privatekey-file-with-absolute-path*
for e.g
Host bitbucket.org
IdentityFile C:/Users/Sahil/.ssh/id_rsa
Source:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/360004124959-IntelliJ-2019-1-3-Can-t-access-git-using-SSH-keys
Update IDEA 2021.2.3
The bug in Sahil's answer has been fixed and Christian's solution is not needed with the correct entry in your ssh config file for the most common case of one key for one or more hosts. Additional options for complex configurations, such as multiple keys to the same or multiple hosts, can be found in Maddes comprehensive answer on superuser.
ANY inconsistency between ssh-agent and ssh-add leads to a situation where some things work and some don't.
For example, I had the Windows OpenSSH agent running but my path pointed first to the Git for Windows ssh-add. Many such failures are possible given the many ssh implementations out there, so know that you know where things are running from.
To get ssh working in IDEA...
Git for Windows
Install Git for Windows. I put it in C:\Git since, as a standard user without an elevated install, I couldn't write to C:\Program Files.
In Control Panel | User Accounts | Change my environment variables add the Git usr\bin folder to the path after the cmd folder entry already there (e.g. C:\Git\usr\bin for my installation).
Unset environment variable HOME -- it still breaks ssh in this version of IDEA.
In a Windows cmd.exe console, run start-ssh-agent.cmd to start the agent
In IDEA in Settings | SSH Configurations | Authentication type: set it to Key pair OpenSSH or PuTTY and test your connection. Then, make a small change and test Commit and push....
Windows OpenSSH
In Control Panel | User Accounts | Change my environment variables add C:\Windows\System32\OpenSSH to your path. Make sure no other ssh implementation is ahead of this in the path!
Start the OpenSSH agent in Task Manager | Services (or any number of other ways)
Set your IDEA SSH Configuration as #5 above
Keep in mind that, on Windows, ssh in IDEA uses the environment available in a standard Windows command-line console (cmd.exe). If git operations work there, then with the above steps in place, they'll work in IntelliJ.
It has been really long since OP but here is my solution on an execution basis:
You need to open a prompt and set the ENVVAR GIT_SSH_COMMAND.
You need to open IntelliJ from that same prompt.
Example:
> set GIT_SSH_COMMAND=ssh -i C:\\path\\to\\not\\default\\key
> idea
Also the path to not-default-key should use ~ instead of %userprofile% or paths unix-like using /.
I was having this same issue, and while it did have to do with the public key, my issue was concerned with WSL2/Linux and windows .ssh folders. My keys were in my WSL2/linux folder system, but intelliJ was looking in my windows folder system.
I copied my rsa keys from WSL2 to windows, and it worked automatically. In fact, I attempted to have it fail again by removing the keys from the Windows folders, but intelliJ must have it's own keylocker solution, because even without the keys in the Windows .ssh folder intelliJ continued to work.
For a screen capture explaining it you can see it here https://vimeo.com/558267383/74d55415c4
If you're using wsl2 in Clion like me, just add
Host github.com
IdentityFile /home/yieatn/.ssh/github
to /home/user/.ssh/config (create if it doesn't exit). You don't even have to restart IDE.
Adding to Cristian Torres's answer:
For all of you folks struggling with a similar problem on Mac OSX:
In IntelliJ, PyCharm, etc. click Tools -> Create Command-line Launcher...
Open your terminal and execute:
$ export GIT_SSH_COMMAND="ssh -i ~/.ssh/your-custom-private-key"
$ idea
For PyCharm the executable name is charm or /usr/local/bin/charm
Goland: goland or /usr/local/bin/goland
WebStorm: webstorm or /usr/local/bin/webstorm

Clone git repo hosted on a Windows shared folder from Mac OS X

I host a git remote repo on a Windows shared folder. I clone it using:
git clone //git-host-pc/SharedFolder/MyProject/
This command works from a Windows PC, but on a Mac, I get this error:
fatal: repository '//git-host-pc/SharedFolder/MyProject' does not exist
Trying git clone smb://git-host-pc/SharedFolder/MyProject gives me this error - fatal: Unable to find remote helper for 'smb'.
Note: I've found this question has been asked before mine - Use a git repos on a windows share from osx, however the OP there hasn't provided his exact commands, or the error messages, and that's why his question is unanswered.
Edit: I forgot to mention, but the shared folder is visible from the Mac, I can see it in Finder.
I kind of like to think that remote file system access is an OS thing, and that cloning repos is an application-level thing, so this would be my approach:
You should just be able to mount that SMB share with your OS'es functions to a local directory and clone from there, instead of hoping git has a transport for SMB.
How to mount:
Connect to the server on your Mac. Now, on your Mac, from Finder's Go menu, choose "Connect to Server." Enter the IP address you just obtained from your PC, preceded by smb://, as shown:
UPDATE: To use your PC's name instead of IP address, replace the number with the name. So if your PC's name is "MyWindowsBox", you'd use smb://mywindowsbox (not case-sensitive).
If it finds your server, you'll get prompted to enter your network credentials - by default, your Windows username and password:
Where to find the mounted folder:
Once I mounted the //git-host-pc/SharedFolder in that way, I found it in /Volumes/SharedFolder.
I've written this answer for those curious to know what git means by Unable to find remote helper for 'smb'
Git requires a helper program whenever it sees a URI such as ftp:// or smb://
When git encounters a URL of the form <transport>://<address>, where
<transport> is a protocol that it cannot handle natively, it
automatically invokes git remote-<transport> with the full URL as the
second argument
Source: https://git-scm.com/docs/git-remote-helpers
Basically you do not have git remote-smb installed. You can use git help -a to see what helpers you have installed.
Until somebody writes a git remote-smb helper, it's probably best to just mount the drive you want as mentioned in another answer.

Need help setting up a git server on windows

i'm trying to set up a git server on Windows, but i'm having some issues getting it all to work.
I have locally created a normal repository, and remotely i created a bare repository. On the local repository i added a single text file and committed it, but when I try to push it into the remote repository I always get the following message:
fatal: protocol error: bad line length character: fata
I searched SO and other sources, and most of them suggest it's an issue regarding command echos. I'm using freeSSHd as a SSH solution (remote repository is hosted on a windows server), and I tried to use both the git bash and the windows CMD as a command shell.
I start CMD with /Q to disable echoing and /K to change directory to a directory where repositories are located, so I don't think that would be a problem.
Using the remote desktop, i can clone the repository to a folder next to it, and using the git bash locally i can access the SSH shell and also clone the repository in the same way. But using git clone ssh://<address>:/myRepo.git I always get the above message (The SSH's working folder is the same where the repository is located). Does anyone have any idea what's going on? How can I see what command is triggering the error, and how can I see the full error message?
I also met the same error using freeSSHd as a ssh solution for git server on Windows. I couldn't find a solution for a whole day and gave up. :(
Later I found another powerful ssh server from Bitvise called WinSSHD worked well. It has free version for personal use. I suggest you to switch to it. Though I'd also like to know if there's a fix to the error we both met.
To setup ssh server with WinSSHD is quite simple, and you can add virtual accounts with private/public key access.
The key part is to setup the ssh access for git server. Please follow the steps of the blog here.
It should work well for Windows git client. For Mac, you may meet an error as follows.
grp.sh: No such file or directory
fatal: Could not read from remote repository.
To fix it, you need to create the two files gup.sh and grp.sh in your git bin directory (GIT_PATH/bin or GIT_PATH/libexec/git-core configured in system environment variable PATH) in your git server.
The content of gup.sh:
git-upload-pack.exe $*
The content of grp.sh:
git-receive-pack.exe $*

Jenkins can not clone Git repository over Git/SSH on Windows

I have successfully cloned Git repository in Jenkins over Git/SSH on Windows 2008 32-bit. When I tried to do the same on Windows 2008 64-bit, Console Output page gets stuck here:
Démarré par l'utilisateur anonymous
Checkout:book / C:\Jenkins\workspace\book - hudson.remoting.LocalChannel#1da691a
Using strategy: Default
Last Built Revision: Revision 5d7ce4ae23c91fb201ee005e6db17bcd795ca965 (origin/HEAD, origin/master)
Checkout:book / C:\Jenkins\workspace\book - hudson.remoting.LocalChannel#1da691a
Cloning the remote Git repository
Cloning repository origin
When I stop the build (after a few minutes of being stuck there), I get the rest of the error message:
ERROR: Error cloning remote repo 'origin' : Could not clone git#github.com:zeljkofilipin/watirbook.git
ERROR: Cause: Error performing command: C:\Git\bin\git.exe clone --progress -o origin git#github.com:zeljkofilipin/watirbook.git C:\Jenkins\workspace\book
null
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1042)
at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:968)
at hudson.FilePath.act(FilePath.java:785)
at hudson.FilePath.act(FilePath.java:767)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:968)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1193)
at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:567)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:455)
at hudson.model.Run.run(Run.java:1404)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:230)
I can clone the repository via Git read-only URL git://github.com/zeljkofilipin/watirbook.git from Jenkins on both machines
I can clone via Git/SSH URL git#github.com:zeljkofilipin/watirbook.git from the command line on both machines
I can clone via Git/SSH URL from Jenkins on 32-bit machine, but not on 64-bit machine.
The only difference I can notice between the two machines (not counting that one is a virtual machine on my laptop, and another is a real machine in Switzerland) is that the first one is 32-bit and the second one is 64-bit.
Not sure if that could be related, but 32-bit machine has location set to Croatia, and 64-bit machine to Switzerland (as you can see from Git output in French).
For more information please see my blog post: Jenkins, Windows and Git
I've gone through these pains recently. Especially frustrating is the lack of error logs in this scenario: probably because MSysgit prompts user on the console when trying to recover - which doesn't get through Jenkins console.
Based on my experience here are a few key elements to watch for:
a mix of both Msysgit and Cygwin installed: MSysgit worked better for me- but I assume you're using that too
some people have more luck with <MSYSGIT_ROOT>\cmd\git.cmd than <MSYSGIT_ROOT>\bin\git.exe
making sure your slave runs as the same user (which is not the default upon service-based installs).. - oh I see you got that too
setting HOME variable for windows slaves explicity
basically make sure the same .ssh keys are reached when under Jenkins.
for debugging, I found it useful to create a test job with no SCM, but run git clone in an "Execute shell/batch" build step. That should reveal a bit more info. BTW, you can do an env in the same step and maybe ls %HOME%/.ssh
I think the above is what gave me a working a Windows 7 64bit Jenkins slave with git support - although I thought this had more to do with some other fine config detail than with 64 vs 32 bits. Good luck anyhow!
In the latest version of git, had to use %GIT_HOME%/cmd/git.exe, rather than %GIT_HOME%/bin/git.exe and figuring out the home directory of the user running the jenkins service.
Another issue i faced with was, ssh.exe was not looking at the %userprofile%/.ssh folder for the key files. Instead it was looking to the folder C:\Program Files (x86)\Git\.ssh which was empty and which causes a hang due to ssh authentication prompt on the machine where git repo located.
We just copied the key files under %userprofile%/.ssh to C:\Program Files (x86)\Git\.ssh and the problem is resolved.
Notes from a hard learned lesson.
I had problems getting the ssh to work running Jenkins as a named user account for ssh+git.
Here is what I had to do to solve the problem:
Generate the key using ssh-keygen (note where they are located)
Set "HOME" to this location
I tried with puttygen and GET_SSH=plink that all failed very bad but no clear errors.
When you have to use any configuration options from a per-user configuration file eg. ~/.ssh/config you can put them in C:\Program Files (x86)\Git\etc\ssh\ssh_config, the key files can be put in C:\Program Files (x86)\Git.ssh
If your account is attached to domain. Then you need to make sure user for which the Jenkins Slave is ran. For the purpose open Settings->Properties of "Jenkins Slave"->Log On. and choose necessary user from domain for correct execution.
Since my Windows Jenkins was a slave, I needed to configure that node to find the git in cmd instead of bin as described by inger. To do this, go to Manage Jenkins, Manage Nodes, click on the appropriate node, click on Configure and then go to the Tool Locations. Find git in the drop-down and then specify the path to git.exe (including git.exe), like C:\Program Files\Git\cmd\git.exe.
I confirmed that the cmd/git.exe worked differently than the bin/git.exe from both command-line and with a temporary jenkins job using the git command (instead of an scm repo).
https://wiki.jenkins-ci.org/display/JENKINS/GitHub+Plugin
Just add a ssh-enabled user logon to Jenkins and it should work smoothly.

How to git clone a repo in windows from other pc within the LAN?

I have this git repo "c:/xampp/htdocs/**" in my main PC and its IP address is 192.168.0.6. Now I want to git clone this repo from ubuntu-server which running on a Vmware Player in my main PC.
I did
git clone \\192.168.0.6\c:\xampp\htdocs\****
and
git clone //192.168.0.6/c:/xampp/htdocs/****
from ubuntu-server and neither worked.
fatal: could not create work tree dir '****'.: Permission denied
What did I wrong?
what should I do?
You should use the command git daemon to host your repo, like this:
In your computer that will act as a server:
git daemon --base-path=<path_to_folder_containing_project_folder> --export-all
(please note that path_to_folder_containing_project is the folder containing your projects folders, it will provide all projects under that folder)
In your client:
git clone git://<local ip>/<project name>
The cloned repo will have its origin pointing to the server in your LAN, so you may want to use git remote set-url origin to point it to the original origin.
You may want to run git daemon with the --verbose option to get more details in case you run into problems.
Make sure that your c:/xampp/htdocs folder (or sub folders of it) is shared in windows, so you can navigate on the network by this address:
\\192.168.0.6\htdocs
Then you clone by using file:////. Note that there are four slashes:
git clone file:////192.168.0.6/htdocs/somerepo.git
To access the repo, you must either share it on 192.168.0.6 or must be the same domain user as the one that owns the file on 192.168.0.6.
If you share the directory on 192.168.0.6 (e.g. with share name myrepo), you access it with //192.168.0.6/myrepo.
If you are logged in on your box with a user accout that is known on 192.168.0.6, you could try accessing the repo through the administrative shares:
//192.168.0.6/c$/xampp/htdocs/...
Always use forward slashes.
Another alternative would be using SSH to access the remote machine.
Using explorer (smb) to mount the remote repository as a network share is the easiest way. I'm not entirely sure, but I think you paths might be wrong. Try file:///192.168.0.6\c:\xampp... instead.
There are two things that might have gone wrong for you:
You don't have read permission on the remote repository
You don't have write permission in the location you want to create your repository ( the current working directory or the directory you specify as second argument to git clone)
And also check if your samba server works for normal file access.
To make git repo on Windows local network you'd need to do the following:
Create new repo
git init --bare projectName.git
Share this folder (projectName.git) with the users you need
Find your PC ip with ipconfig command (e.g. 192.168.2.101)
Run this command from some user's machine
git clone //192.168.2.101/projectName.git
Note: open \\192.168.2.101 in finder to see the correct path to the projectName.git (e.g. //192.168.2.101/some/path/projectName.git)
I recently ran into this error while trying to clone a repository in a remote pc to a local pc within the same LAN network.
The solution was to first make sure the drive location in the remote pc had the correct access rights for the local PC(Read/Write-which can be set using windows sharing options)
Copy the path of the remote repository. In your local pc paste the path in a windows explorer window. Then copy its directory address and paste it into any browser.
Now you should get a link with the hostname and the correct cloning URL format.
Use this link to clone the repository in the local pc.
Hope this helps.
Cheers.
"I have a few different computers that I use at home and I wanted to set up GIT that I can access my code from any of them. It took me a bit because I was too used to working with a client-server model where I designate one machine as the "server" that holds the repository and everything else was a client. Instead, GIT seems to operate more like a merge tool and every local copy is its own "master." Once I understood that, it turns out that setting up GIT is very simple and just needs GIT itself and SSH".
To read more you can check this link:
http://blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html

Resources