Module: Git
- Defined in:
- lib/git.rb,
lib/git/lib.rb,
lib/git/log.rb,
lib/git/base.rb,
lib/git/diff.rb,
lib/git/path.rb,
lib/git/index.rb,
lib/git/stash.rb,
lib/git/author.rb,
lib/git/branch.rb,
lib/git/object.rb,
lib/git/remote.rb,
lib/git/status.rb,
lib/git/stream.rb,
lib/git/stashes.rb,
lib/git/branches.rb,
lib/git/repository.rb,
lib/git/working_directory.rb
Overview
Git/Ruby Library
This provides bindings for working with git in complex interactions, including branching and merging, object inspection and manipulation, history, patch generation and more. You should be able to do most fundamental git operations with this library.
This module provides the basic functions to open a git reference to work with. You can open a working directory, open a bare repository, initialize a new repo or clone an existing remote repository.
- Author
-
Scott Chacon ([email protected])
- License
-
MIT License
Defined Under Namespace
Classes: Author, Base, Branch, Branches, Diff, GitExecuteError, GitTagNameDoesNotExist, Index, Lib, Log, Object, Path, Remote, Repository, Stash, Stashes, Status, Stream, StreamCommit, StreamData, StreamFileCopy, StreamFileDelete, StreamFileDeleteAll, StreamFileModify, StreamFileRename, StreamMark, WorkingDirectory
Constant Summary collapse
- VERSION =
'1.0.4'
Class Method Summary collapse
-
.bare(git_dir, options = {}) ⇒ Object
open a bare repository.
-
.clone(repository, name, options = {}) ⇒ Object
clones a remote repository.
-
.export(repository, name, options = {}) ⇒ Object
Export the current HEAD (or a branch, if
options[:branch]
is specified) into thename
directory, then remove all traces of git from the directory. -
.init(working_dir = '.', options = {}) ⇒ Object
initialize a new git repository, defaults to the current working directory.
-
.open(working_dir, options = {}) ⇒ Object
open an existing git working directory.
Class Method Details
.bare(git_dir, options = {}) ⇒ Object
open a bare repository
this takes the path to a bare git repo it expects not to be able to use a working directory so you can’t checkout stuff, commit things, etc. but you can do most read operations
57 58 59 |
# File 'lib/git.rb', line 57 def self.(git_dir, = {}) Base.(git_dir, ) end |
.clone(repository, name, options = {}) ⇒ Object
clones a remote repository
options
:bare => true (does a bare clone)
:repository => '/path/to/alt_git_dir'
:index => '/path/to/alt_index_file'
example
Git.clone('git://repo.or.cz/rubygit.git', 'clone.git', :bare => true)
94 95 96 |
# File 'lib/git.rb', line 94 def self.clone(repository, name, = {}) Base.clone(repository, name, ) end |
.export(repository, name, options = {}) ⇒ Object
Export the current HEAD (or a branch, if options[:branch]
is specified) into the name
directory, then remove all traces of git from the directory.
See clone
for options. Does not obey the :remote
option, since the .git info will be deleted anyway; always uses the default remote, ‘origin.’
105 106 107 108 109 110 |
# File 'lib/git.rb', line 105 def self.export(repository, name, = {}) .delete(:remote) repo = clone(repository, name, {:depth => 1}.merge()) repo.checkout("origin/#{[:branch]}") if [:branch] Dir.chdir(repo.dir.to_s) { FileUtils.rm_r '.git' } end |
.init(working_dir = '.', options = {}) ⇒ Object
initialize a new git repository, defaults to the current working directory
options
:repository => '/path/to/alt_git_dir'
:index => '/path/to/alt_index_file'
80 81 82 |
# File 'lib/git.rb', line 80 def self.init(working_dir = '.', = {}) Base.init(working_dir, ) end |
.open(working_dir, options = {}) ⇒ Object
open an existing git working directory
this will most likely be the most common way to create a git reference, referring to a working directory. if not provided in the options, the library will assume your git_dir and index are in the default place (.git/, .git/index)
options
:repository => '/path/to/alt_git_dir'
:index => '/path/to/alt_index_file'
71 72 73 |
# File 'lib/git.rb', line 71 def self.open(working_dir, = {}) Base.open(working_dir, ) end |