I am using Amazon Ec2 . I am trying to create a Remote Repo on the Ec2 server to which I can check in code and run my server from there .
Ec2 Server
Here is created two folders
/home/ubuntu/project.git <---- Repo
/home/ubuntu/project <---- Source files to run server
I followed the instructions given here - http://blog.soarez.com/post/56644329478/deploy-a-node-js-service-on-ec2-with-git
Now from my local computer , I pushed the source files to project.git . It works fine . Files get pushed into the repo.
Now how do I get the files from the project.git to the project folder . I tried doing this , but it doesnt work -
cd ~/project.git
GIT_WORK_TREE=/home/ubuntu/project git checkout -f
cd ~/project.git
GIT_WORK_TREE=/home/ubuntu/project git checkout -f
This is the right way to checkout files from a bare repo.
But if the variable isn't see as exported by the git checkout command, you can wrap that in a script, like "unable to set GIT_WORK_TREE
variable in a bare repository when using post_update
hook" did.
That is what makes the a post-receive
work, in the directory ~/project.git/hooks/
.
来源:https://stackoverflow.com/questions/18803105/checkout-source-files-from-local-git-repo-to-local-folder