2 # Add the directory containing this file to the start of the load path if it
4 $:.unshift(File.dirname(__FILE__)) unless
5 $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
11 require 'git/repository'
13 require 'git/working_directory'
18 require 'git/branches'
26 require 'git/raw/repository'
31 # This provides bindings for working with git in complex
32 # interactions, including branching and merging, object
33 # inspection and manipulation, history, patch generation
34 # and more. You should be able to do most fundamental git
35 # operations with this library.
37 # This module provides the basic functions to open a git
38 # reference to work with. You can open a working directory,
39 # open a bare repository, initialize a new repo or clone an
40 # existing remote repository.
42 # Author:: Scott Chacon (mailto:schacon@gmail.com)
43 # License:: MIT License
48 # open a bare repository
50 # this takes the path to a bare git repo
51 # it expects not to be able to use a working directory
52 # so you can't checkout stuff, commit things, etc.
53 # but you can do most read operations
54 def self.bare(git_dir, options = {})
55 Base.bare(git_dir, options)
58 # open an existing git working directory
60 # this will most likely be the most common way to create
61 # a git reference, referring to a working directory.
62 # if not provided in the options, the library will assume
63 # your git_dir and index are in the default place (.git/, .git/index)
66 # :repository => '/path/to/alt_git_dir'
67 # :index => '/path/to/alt_index_file'
68 def self.open(working_dir, options = {})
69 Base.open(working_dir, options)
72 # initialize a new git repository, defaults to the current working directory
75 # :repository => '/path/to/alt_git_dir'
76 # :index => '/path/to/alt_index_file'
77 def self.init(working_dir = '.', options = {})
78 Base.init(working_dir, options)
81 # clones a remote repository
84 # :bare => true (does a bare clone)
85 # :repository => '/path/to/alt_git_dir'
86 # :index => '/path/to/alt_index_file'
89 # Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true)
91 def self.clone(repository, name, options = {})
92 Base.clone(repository, name, options)