-3

So I want to have a git repo on my server which holds my website, one I can push to and users can see from the domain name.

I ssh'd into my server and did:

git --bare init

This was located in the file structure /public_html/project. Then on my local repo I did:

git init

added the remote and did an initial commit and pushed up to the server.

When I navigate to the server (staging.com/public_html/project) I just see the git files, where are my actual website files which the server can render?

Or is this a poor understanding of GIT?

War10ck
  • 11,732
  • 7
  • 38
  • 50
user2389087
  • 1,422
  • 3
  • 13
  • 32

2 Answers2

2

Bare repositories have no working directory. There are no checked out copies of any files for you to work with, or for your web server to serve. That's the whole point of the --bare option you used. If you want there to be usable files on the remote, don't use --bare.

meager
  • 209,754
  • 38
  • 307
  • 315
  • Even if it wasn't `--bare`, he would have to `git pull` on the server after each push. – KurzedMetal Sep 08 '14 at 11:46
  • I used bare as i was getting an error when using a working remote: error: refusing to update checked out branch: refs/heads/master remote: error: By default, updating the current branch in a non-bare repository remote: error: is denied, because it will make the index and work tree inconsistent remote: error: with what you pushed, and will require 'git reset --hard' to match remote: error: the work tree to HEAD. – user2389087 Sep 08 '14 at 11:50
  • 1
    @user2389087, this support's KurzedMetal's comment on your question. Git isn't meant as a deployment tool, and using it as one can be tricky. You can't simply `git push` into a directory on a remote machine, at least not out of the box. You'll need to `git pull` from the server, or set up a post receive hook to automate your site deployment, or something else like that. – Chris Sep 08 '14 at 11:57
1

I agree with the comments above

Using Git to deploy isn't the best solution

In the end I set up git as a working tree Set up a post receive hook to update the head each time

If anyone else wants to follow this path, these links helped

Git Post-Receive Hook for Website Staging

Using git to deploy a website

Community
  • 1
  • 1
user2389087
  • 1,422
  • 3
  • 13
  • 32