I'd like to do update my existing checkout from git, but without being inside of that 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 don't really understand git-dir
and work-tree
, can someone explain what am I doing wrong?
To change this current working directory, you can use the "cd" command (where "cd" stands for "change directory").
git fetch really only downloads new data from a remote repository - but it doesn't integrate any of this new data into your working files. Fetch is great for getting a fresh view on all the things that happened in a remote repository.
git-dir
should point to the .git
folder of your local copy (yours points to the remote repository you cloned from):
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 -C
which simplifies this to:
~/tmp> git -C /Users/jhoffmann/tmp/my-project/ pull
Already up-to-date.
(taken from this answer)
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