Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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

like image 456
Dandan Avatar asked Dec 11 '11 04:12

Dandan


People also ask

Why git push is not working?

If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.

Does git push push everything?

No, git push only pushes commits from current local branch to remote branch that you specified in command.


1 Answers

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.)

like image 148
manojlds Avatar answered Nov 07 '22 12:11

manojlds