Difference between revisions of "Git"
m (→Updating just a single file) |
(→Webhooks) |
||
Line 31: | Line 31: | ||
*[http://progit.org/book/ch4-7.html Set up a Gitosis server] | *[http://progit.org/book/ch4-7.html Set up a Gitosis server] | ||
*[http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux How to set up your own private Git server on Linux]. Contains a comparison between Gitolite and Gitosis. This author, having tried both, has a preference for Gitolite. | *[http://tumblr.intranation.com/post/766290565/how-set-up-your-own-private-git-server-linux How to set up your own private Git server on Linux]. Contains a comparison between Gitolite and Gitosis. This author, having tried both, has a preference for Gitolite. | ||
+ | |||
+ | == Github WebHooks == | ||
+ | Github offers notifications via [https://developer.github.com/webhooks/ WebHooks] so that services can respond dynamically to events occurring on their repositories. We use this to have some clones on the server automatically update whenever a ''push'' occurs. Here's an example PHP script that responds to Github notifications (they must be configured as form data not JSON format for this script to work). | ||
+ | {{code|<php><?php | ||
+ | if(array_key_exists('HTTP_X_HUB_SIGNATURE', $_SERVER)) { | ||
+ | $repo = json_decode($_POST['payload'])->repository->name; | ||
+ | if( $repo === 'extensions' ) $repo = '/var/www/new-extensions'; | ||
+ | elseif( $repo === 'tools' ) $repo = '/var/www/tools'; | ||
+ | else $repo = false; | ||
+ | if( $repo ) exec( "cd $repo && sudo git pull" ); | ||
+ | }</php>}} | ||
== See also == | == See also == |
Revision as of 15:37, 11 May 2015
Git is a distributed revision control / software code management project created by Linus Torvalds, initially for the Linux kernel development.
Git's design was inspired by BitKeeper and Monotone. Git was originally designed only as a low-level engine that others could use to write front ends such as Cogito or StGIT. However, the core Git project has since become a complete revision control system that is usable directly. Several high-profile software projects now use Git for revision control, most notably the Linux kernel, X.org Server, One Laptop per Child (OLPC) core development, and the Ruby on Rails web framework.
Git differs from systems such as CVS, or SVN in that the database is maintained beside the working filesystem on peers. Each peer is easily sync'ed to any other by using push/pull or fetch. In subversion you use three main directory structures;
- trunk
- branch
- tag
In git the trunk is equivalent to HEAD, and is a sha1sum to the latest commit. Branches are used to fork development from the HEAD if for example bug fixing is required. A tag in git is just a named sha1sum commit which is effectilvely a static reference to a particular snapshot of code.
If a repository is cloned, git tracks the master which is the latest commit on the remote repository, as well as the origin/master which is the last known commit from the source sourced repository. This is updated if your remote changes are pushed back to the repository you cloned from.
Contents
Using Git to update Wikimedia extensions
This clones the entire repo including all revisions to your local system. To change the local directory structure to a specific revision, use checkout with the required commit hash, e.g.
Reverting a working copy
Updating just a single file
Links to Setting up Git Servers
- Set up a bare Git server
- Get up a Gitolite server
- Set up a Gitosis server
- How to set up your own private Git server on Linux. Contains a comparison between Gitolite and Gitosis. This author, having tried both, has a preference for Gitolite.
Github WebHooks
Github offers notifications via WebHooks so that services can respond dynamically to events occurring on their repositories. We use this to have some clones on the server automatically update whenever a push occurs. Here's an example PHP script that responds to Github notifications (they must be configured as form data not JSON format for this script to work).
See also
- 11 July 2013 - our news item about setting up our GitHub mirror
- ProGit.org - everything you wanted to know about using git.
- Debianize Github Projects And Upload to Ubuntu PPA
- Stop Using Git! (ironic) by Matthew McCullough
- Duplicate a Git repository
- Decentralised
- Software