How to use 'git pull' from the command line?
Asked Answered
T

3

24

We were using a build script to automate our publishing process and it was working with SVN but now we are using Git and need to do some command line operations to pull from our remote repository.

I was able to follow the guide here and using the Git bash it works great. However, I need to perform these tasks from the Windows command line so that they can be executed by the script.

git pull origin master works in the Git bash.

cd "c:\program files (x86)\git\bin
git --git-dir=path\to\.git pull origin master 

fails with an error

Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Obviously my SSH key is not being used properly or something. I'm so new to this that I really have no clue what to do.

Thinking answered 22/3, 2012 at 20:49 Comment(0)
W
16

Try setting the HOME environment variable in Windows to your home folder (c:\users\username).

( you can confirm that this is the problem by doing echo $HOME in git bash and echo %HOME% in cmd - latter might not be available )

Wonderland answered 22/3, 2012 at 20:53 Comment(3)
Do you know where I should "set the HOME environment variable"?Thinking
Adding a system variable called "HOME" with a value of "%USERPROFILE%" worked. Thank you.Thinking
Mind the case-sensitiveness. It should be $HOME and not $homeHonoria
I
1

Open up your git bash and type

echo $HOME

This shall be the same folder as you get when you open your command window (cmd) and type

echo %USERPROFILE%

And – of course – the .ssh folder shall be present on THAT directory.

Illuminating answered 22/3, 2012 at 20:54 Comment(0)
F
1

One more option is to add the path of the privatekey file like this in terminal:

ssh-add "path to the privatekeyfile"

and then execute the pull command

Forgo answered 21/5, 2013 at 4:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.