Git

From Organic Design wiki
Revision as of 18:01, 5 March 2015 by Nad (talk | contribs) (useful git commands)
Broom icon.svg The content of this article requires cleaning up to meet OD's quality standards. Check the wiki best practices for guidelines on improving article and categorisation quality.

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.

Using Git to update Wikimedia extensions

git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/<EXT>.git

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.

git checkout 6854b712f200a833220c156a2499f502317c20c1

Reverting a working copy

<bash>git reset --hard <branch/tag/rev></bash>

Updating just a single file

<bash>git fetch</bash>

followed by


<bash>git checkout origin/master -- path/to/file</bash>

Links to Setting up Git Servers

See also