Git pull and specify directory?
i would like to run a git pull and specify the directory. some say using –git-dir and –work-tree should work but such as
git --git-dir=/var/www/.git --work-tree=/var/www pull
put this returns a “cannot be used without a working tree”. The only time i can get this to work is if i use “.”, “..” or any directory above the current directory
this post suggests maybe a bug?
git pull while not in a git directory
in the end i need to run a sudo git pull in a single line. i welcome any work arounds. thanks
4 Solutions collect form web for “Git pull and specify directory?”
Use sudo and give the command as an argument to sh?
sudo sh -c 'cd /dir && git pull'
In the two years since this question was answered, Git 1.8 came out which supports calling
git in other directories using the
git -C /var/www pull
You are using
--work-dir, which is not the right paramter. It is
--work-tree and should work for what you want. Or you can just do
cd /var/www && git pull if you wanted the pull to be in a single command / line.
On Windows in MINGW64:
git -C "C:\Trunk190117\crewcontrol-source" pull
git -C /c/Trunk190117/crewcontrol-source pull