0

The same sequence of git commands works well on Linux Ubuntu, but does not work on Windows. On Windows, I have tried this with Git Bash, using "run as administrator", Windows Powershell, and Windows command line, using "run as administrator". Why?

git init
git remote add <remote name> <remote URL>
git pull <remote name> <remote branch>

In Linux, this produces the challenge for the remote credentials, then produces the remote repository. In Windows, this produces no response, no error, and no remote repository.

Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
user3781353
  • 41
  • 1
  • 6
  • 2
    Yes, "git bash" should work on Windows just as "git commands" do on Windows. Just about any other Windows client should work, too. SUGGESTIONS: 1) Focus on Git bash (download from https://git-scm.com/downloads). 2) Try `git clone https:xxx` of your remote repo. What happens? 3) Update your post with the results. – FoggyDay Jan 29 '20 at 01:04

3 Answers3

2

It seems to me you're going about it the wrong way. Generally you use the git init command when you are creating something from scratch. After performing a git init, doing a pull is the wrong command because there has not been anything pushed to the remote yet. If the remote/server already has the branch you want, I think you would:

git clone <remote URL>

Then from inside the folder created as a result of the git clone command:

git checkout --track origin/<branch>



Or do it all in one shot:

git clone -b <branch> --single-branch <remote URL>
benhorgen
  • 1,928
  • 1
  • 33
  • 38
  • git clone, copied directly from bitbucket, produces no response and no repository on Windows 10 Pro. The same git clone command works well in a Linux Ubuntu 18.05 implementation. – user3781353 Jan 29 '20 at 15:23
  • 1
    @user3781353: git on Windows 10 definitely "works"... and you're failing to give us sufficient information to figure out why it's not working in your scenario. SUGGESTIONS: 1) Thank you for confirming you tried "git clone". Let's stick with this test. 2) Please use "git bash" from https://git-scm.com/downloads. 3) Try cloning a repo on GitHub (to isolate the problem), 4) Failing all else, please enable verbose logging: https://stackoverflow.com/a/49050903/3135317. 4) UPDATE YOUR POST WITH THE RESULTS. – FoggyDay Jan 29 '20 at 15:41
0

Windows 10 as of build 1803 has an openssh client built-in.

But: the ssh-agent for it runs as a Windows service, and isn't enabled by default. And you have to add keys to it using ssh-add in a cmd.exe window, not git bash, because it wants to allocate a tty. And: git tries to use its own ssh, which at that point it may or may not be able to, depending on how you have things configured.

So try setting GIT_SSH_COMMAND='c:\Windows\System32\OpenSSH\ssh.exe' and then try it again.

GaryO
  • 5,873
  • 1
  • 36
  • 61
0

The workaround was to change the communication mode to ssh. At least on Bitbucket, the ssh string is available by changing the clone string to ssh, and modifying the clone string as appropriate for git remote.

Then you need to add an ssh key to bitbucket. See direction to add an ssh key at How to solve Permission denied (publickey) error when using Git?

user3781353
  • 41
  • 1
  • 6