Dandan
Dandan

Reputation: 680

git push from local machine to server works but not files on server

thanks for any help.

I have a git repo on my local machine (mac osx lion) which I'm trying to push to my ec2 instance with Ubuntu.

On the ec2 server I've done:

cd /u/apps
mkdir stuff.git
cd stuff.git
git init --bare
git update-server-info

On my local machine I've got the folder 'stuff' which just has a text file.

cd stuff
git init
git add .
git commit -m "initial commit"
git remote add origin [email protected]:/u/apps/stuff.git
git push origin master

Counting objects: 6, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 477 bytes, done.
Total 4 (delta 0), reused 0 (delta 0)
To [email protected]:/u/apps/stuff.git
95d5ae5..4b5a30f  master -> master

everything appears to be fine but when I check the server the new text file called 'hello.txt' hasn't been added. All I see is:

/u/apps/stuff.git$ ls
branches  config  description  HEAD  hooks  info  objects  refs

Any thoughts on what I may have overlooked?

Cheers

Upvotes: 6

Views: 1810

Answers (1)

manojlds
manojlds

Reputation: 301147

Yes, you don't see the files because you created a bare repo ( git init --bare) as it should be. Bare repos don't have a working tree.

If you are trying to get the file at a particular path, from the bare repository on thte server, you must setup a post-receive hook and have it checkout. The post receive hook will have something like:

GIT_WORK_TREE=/path/where/to/checkout git checkout -f

(the above can also be run manually from the repo on the server if you want.)

Upvotes: 7

Related Questions