Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use 'git pull' from the command line?

Tags:

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.

like image 291
Chev Avatar asked Mar 22 '12 20:03

Chev


People also ask

How do you use the pull command?

The git pull command is actually a combination of two other commands, git fetch followed by git merge . In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. Once the content is downloaded, git pull will enter a merge workflow.

Can I open pull request from command line?

Now you can use the gpr command straight from your command line to automatically open a page to compare two remote branches and start the Pull Request process automatically!


2 Answers

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 )

like image 62
manojlds Avatar answered Oct 07 '22 20:10

manojlds


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.

like image 25
eckes Avatar answered Oct 07 '22 22:10

eckes