Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull and specify directory?

Tags:

git

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

like image 431
jadent Avatar asked Feb 06 '12 04:02

jadent


People also ask

Can I git pull a specific folder?

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.

How do I find a specific folder in a git repository?

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.


1 Answers

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
like image 61
dotancohen Avatar answered Oct 14 '22 03:10

dotancohen