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
Current git versions support Sparse checkout which allows you to clone or fetch only a particular folder from a very big repository. Let's see how we can achieve it. Creating of the branch is a totally optional step but it is advisable to create.
Step1: Input github url to the field at the top-right. Step2: Press enter or click download for download zip directly or click search for view the list of sub-folders and files. Step3: Click "Download Zip File" or "Get File" button to get files.
In the two years since this question was answered, Git 1.8 came out which supports calling git
in other directories using the -C
flag:
git -C /var/www pull
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With