This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| tutorials:scmgit-intro [2012/04/30 19:11] – minor formatting memnon | tutorials:scmgit-intro [2012/05/05 20:31] (current) – Added missing public access section, $ID memnon | ||
|---|---|---|---|
| Line 128: | Line 128: | ||
| Git also provides the command "git pull" to do a fetch followed by a merge. This is unlike CVS and Subversion, where " | Git also provides the command "git pull" to do a fetch followed by a merge. This is unlike CVS and Subversion, where " | ||
| + | |||
| + | |||
| + | ===== Creating a public access, read only repo ===== | ||
| + | Once you have your repo setup for you to do your work in, you may have a need to make your work public. Making it public allows for other users to pull specific version of your project without having to have development rights. A slight modification to your repo is needed and some webspace to host it. | ||
| + | |||
| + | === Setup some webspace === | ||
| + | To host a readonly public access version of your repo you will need to setup some space in your html directory. For our example our public repo will be accessable at http:// | ||
| + | |||
| + | mkdir ~/ | ||
| + | hooks/ | ||
| + | |||
| + | In your repo directory for the project there is a directory that contains a set of scripts which are called at different times during your interaction with git. For more information about the " | ||
| + | |||
| + | The script we will need to modify is post-update. This script is called after an update has occured on the server side of your repo. | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/sh | ||
| + | # | ||
| + | # File: ~/ | ||
| + | # | ||
| + | # Description: | ||
| + | # | ||
| + | |||
| + | # Location of your repo on the server | ||
| + | GIT_DIR=/ | ||
| + | |||
| + | # Location of your public version of the repo | ||
| + | HTTP_DIR=/ | ||
| + | |||
| + | # Update local repo info | ||
| + | git update-server-info | ||
| + | |||
| + | # Make sure a clean copy is moved | ||
| + | rm -rf $HTTP_DIR | ||
| + | cp -rf $GIT_DIR $HTTP_DIR | ||
| + | chgrp -R nobody $HTTP_DIR | ||
| + | |||
| + | # Directories must have Read and Execute Permissions | ||
| + | # for apache to be able to navigate them. | ||
| + | for d in `find $HTTP_DIR -type d`; do | ||
| + | chmod a+rx $d | ||
| + | done | ||
| + | |||
| + | # Files must have Read Permissions for apache | ||
| + | # to be able to read them. | ||
| + | for f in `find $HTTP_DIR -type f`; do | ||
| + | chmod a+r $f | ||
| + | done | ||
| + | |||
| + | # Display a message on the client side to show | ||
| + | # the action has been performed. | ||
| + | echo " | ||
| + | </ | ||
| + | |||
| + | Now that you have setup this script make sure its executable. | ||
| + | | ||
| + | chmod a+x ~/ | ||
| + | |||
| + | You can now run the script directly or wait until you have committed and pushed an update to your server. | ||
| + | |||
| + | === Verifying script is run. === | ||
| + | |||
| + | When you push an update to your private development repo, a new output has been added by our script. | ||
| + | |||
| + | $ git push | ||
| + | Counting objects: 5, done. | ||
| + | Compressing objects: 100% (2/2), done. | ||
| + | Writing objects: 100% (3/3), 256 bytes, done. | ||
| + | Total 3 (delta 1), reused 0 (delta 0) | ||
| + | remote: Updated Public Access | ||
| + | To user@sdf.org: | ||
| + | | ||
| + | $ | ||
| + | |||
| + | In the above example there is a new line labled " | ||
| + | |||
| + | **Private Access**: git clone user@sdf.org: | ||
| + | **Public Readonly Access**: git clone http:// | ||
| ===== Further Reading ===== | ===== Further Reading ===== | ||
| Line 143: | Line 221: | ||
| Best look online for more in-depth tutorials.. | Best look online for more in-depth tutorials.. | ||
| I haven' | I haven' | ||
| + | |||
| + | $Id: scmgit-intro.html, | ||