where are project files in remote repo in Git?

谁都会走 提交于 2020-01-05 06:54:28

问题


I start to use Git and my project VCS. I have created a remote repo using

git init --bare 

in /codes-repo and push changes from local repo to there. then I want to move project files from there to /var/www/project to be accessible for http://.... . but I don't see any project files (index.php,css/,....) at /codes-repo to copy them, there are only git files and folders there. Where are them??


回答1:


A bare repository does not have a checkout. That is to say, a bare repository only holds the commit information - it does not keep a copy of the actual files on disk within the repository folder.

Bare repositories can only be pushed to or pulled from. To get a hold of the files, your best bet is probably to clone the bare repository (as a non-bare clone), and run a checkout at the clone.

Another option, if you're feeling brave, is to convert the bare repository into a non-bare repository (How do I convert a bare git repository into a normal one (in-place)?)




回答2:


To copy the files from a bare repository, you can use git archive

GIT_DIR=~/BARE_REPO git archive --format tar master | tar xvf -

the git archive command will convert the target commit (marter, for example) to tar format, and send to the standard output. You can pipe it to a tar command to extract immediately.

Another way is just checkout the repository.

git checkout ~/BARE_REPO myproject

However, it's not suitable to put this whole directory into you web server. Otherwise your entire .git directory will be accessible. Anyone can get your source code and complete commit history (Of course, you can block these access by .htaccess or nginx setting).




回答3:


A bare repository doesn't have a so-called working directory, so won't have any filesystem objects.

Git still keeps track of contents, commits, tags and so on, but store them packed somewhere. When you git checkout in a nonbare repository, git updates the index (the files in the repository) to reflect the tree-ish object given as the argument.



来源:https://stackoverflow.com/questions/13682144/where-are-project-files-in-remote-repo-in-git

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!