开发者

git push, where are the source code hidden?

i tried to set up git server and deployment server on the same machine for my ror application. I pushed the project from local machine to the git server/deployment server using the following commands:开发者_Python百科

git remote add origin path_to_git_server
git push origin master

Then, on the git server, I found the 'master' file under ~/git/log.git/ref/heads, but nowhere can I find all the source codes. I need to point to the source folders in order it works on apache web server. What did I do wrong here? Thanks.


It is likely that you created a git init --bare repository - this will not work as it is only the git repository and not the working stage. I'm going to set this up as a three machine layout - but it can be run on two or even just one machine.

Machine A (your development machine)

Machine B (your remote repository)

Machine C (your production environment)

(But if you have production, development, and "remote" repository on one machine that's fine too)

When you're ready to push to Machine B (Repo) you commit all your work, stage it just right, then perform a git push (after doing the remote add, etc) this updates the Bare remote repository with all the changes from your machine since the last push (Think of it as syncing the contents of your .git folder on Machine a with the remote repo)

Since Git only cares about the changes of the contents of your files (and not actually about the files or folders themselves - trust me Git does not care about your files - just the content) it doesn't store files one Machine B like you see on your Machine A "Working Stage" Git places those files in the working stage for you to use and develop against - but Git doesn't care about them - again it cares only about the changes to the contents of the "files" since the last time you committed.

To deploy your code you will need to go to Machine C and clone the repository on Machine B - this will sync the ".git" folder down to that machine and then build the subsequent files/folders based off all the content it's tracked. Once you've cloned this repository you can get future updates via git pull

That's about the jist of it. If you have it all on once computer you could do something like:

~/projects/git_project (Your devel area)
/home/repo/git_project.git ("Remote" repo)
/opt/rails/git_project ("Production" machine)

Having a remote repo is redundant on one machine since you can technically pull and push from

~/projects/git_project

to

/opt/rails/git_project

But just keeping the example in line


Repository on the server is a bare repository. By convention it resides in directory named project_name.git.

Bare repository has no checked out working copy of your project's source code, like your local repository does. All source code is inside compressed data files.

To publish source code through a web server you need a web application that can read those files, like Gitweb or Gitosis.

You might want to read What’s the best Web interface for Git repositories? here on SO before choosing one :-)


To use capistrano (or another build or deployment tool) with git you can:

  • use git clone to create normal working copy (normal, non-bare git repository) somewhere on the build server

  • run capistrano from this copy

  • use git pull periodically to keep this copy in sync with common repository.


You possible create a bare repository in server. A bare repository does not have a local checked-out copy of any of the files under reversion control.

If you want to have a checked-out copy on server, use git init without --bare to initialize the git repository and set receive.denyCurrentBranch to ignore in order to allow push command. Also, you need to make sure no one change any file in git repository on server.

See http://toroid.org/ams/git-website-howto for more information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜