Specify a directory for git pull (not the current directory)

I would like to update an existing checkout from git, but not being inside this directory:

-sh-3.2$ pwd
/var/lib/gitolite
-sh-3.2$ git clone repositories/visits.git/
Cloning into 'visits'...
done.
-sh-3.2$ cd visits/
-sh-3.2$ git remote -v
origin  /var/lib/gitolite/repositories/visits.git/ (fetch)
origin  /var/lib/gitolite/repositories/visits.git/ (push)
-sh-3.2$ cd
-sh-3.2$ git --git-dir=/var/lib/gitolite/repositories/visits.git/ --work-tree=/var/lib/gitolite/visits/ pull 
fatal: No remote repository specified.  Please, specify either a URL or a
remote name from which new revisions should be fetched.
-sh-3.2$ cd visits/
-sh-3.2$ git pull
Already up-to-date.
-sh-3.2$ git --version
git version 1.8.2.1
-sh-3.2$ 

I really don’t understand git-dirand work-treecan someone explain what I am doing wrong?

+4
source share
1 answer

git-dirshould point to the folder of .gityour local copy (your point points to the remote repository from which you cloned):

Example:

~/tmp> git clone repositories/my-project.git/
Cloning into 'my-project'...
done.
~/tmp> git --git-dir=/Users/jhoffmann/tmp/my-project/.git \
> --work-tree=/Users/jhoffmann/tmp/my-project/ pull
Already up-to-date.

Git version 1.8.5 introduces -Cthat simplifies this:

~/tmp> git -C /Users/jhoffmann/tmp/my-project/ pull
Already up-to-date.

(taken from this answer )

+6
source

All Articles