4

I've got a website on a VPS and I'd like to create an offline clone using Git.

So what I did on my VPS:

git init
git add .
git commit -m "comment"

Which created a .git folder. I am not sure now how I am supposed to continue in order to clone the git repository to my local machine.

I've tried using: git clone ssh://user@IP/home/user/.git but I get the following messages:

fatal: '/home/user/.git' does not appear to be a git repository 
fatal: Could not read from remote repository.

Can you please let me know what I am missing here?

Paul Hicks
  • 13,289
  • 5
  • 51
  • 78
user3096206
  • 592
  • 3
  • 6
  • 12
  • 3
    To clone the repo you need to indicate the path to the project and not the path to the `.git` folder – Joël Salamin May 05 '15 at 09:36
  • @JoëlSalamin So instead of /home/user/.git just /home/user/ ? Because that didn't work either. Unless you mean something else.. – user3096206 May 05 '15 at 09:41
  • 1
    what is the error thrown now? – Chris Maes May 05 '15 at 09:42
  • 1
    all you need is one command, `git clone ssh://username@site.com:port/remote/dir/public_html /home/user/local/dir` – Garry May 05 '15 at 09:42
  • possible duplicate of [Git "does not appear to be a git repository"](http://stackoverflow.com/questions/10391522/git-does-not-appear-to-be-a-git-repository) – Joe May 05 '15 at 11:25

1 Answers1

4

you should just "ignore" the existence of the .git directory:

git clone ssh://user@IP:/home/user/

should do the trick (if ssh user@IP works of course).

NOTE: not sure it's a good idea to make your whole "user" directory a git repository. using a subdirectory is probably a good idea.

EDIT: in this case file permissions were also an issue in copying files from a linux pc to a windows pc...

Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • Hello Chris, doing this I still get the same error `fatal: '/home/user/' does not appear to be a git repository fatal: Could not read from remote repository.` I've also got .gitignore to ignore everything but public_html which I want to copy – user3096206 May 05 '15 at 09:45
  • in which directory did you do the `git init` command? I suppose in `/home/user/` ? – Chris Maes May 05 '15 at 09:45
  • Yes, I did it on /home/user/ and the .git folder is under there. I've also checked ssh which works. – user3096206 May 05 '15 at 09:47
  • then I suggest you to try it out locally first: create a temporary dir; make it a git repository; and clone it to another directory; check if that works... – Chris Maes May 05 '15 at 09:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76978/discussion-between-chris-maes-and-user3096206). – Chris Maes May 05 '15 at 09:55