Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git pull for a local repository at specified location (instead of pwd)

Tags:

git

pwd is "present working directory". Here's the situation.

pwd:            /path/to/pwd/
git repository: /repo/path/.git/

I want to do a git pull from origin, but without changing my current directory.

To clarify just a little more in case I'm not clear enough, this is the result I want, but I want to do it with one command instead of having to change directories:

$ cd /repo/path
$ git pull origin master
$ cd -
like image 974
Matthew Avatar asked Mar 12 '12 19:03

Matthew


2 Answers

git --work-tree=/repo/path --git-dir=/repo/path/.git pull origin master
like image 89
Justin ᚅᚔᚈᚄᚒᚔ Avatar answered Sep 29 '22 10:09

Justin ᚅᚔᚈᚄᚒᚔ


bash -c "cd /repo/path; git pull origin master"

like image 32
sethcall Avatar answered Sep 29 '22 11:09

sethcall