Class Git::Base
In: lib/git/base.rb
Parent: Object

Methods

add   add_remote   add_tag   apply   apply_mail   archive   bare   branch   branches   cat_file   chdir   checkout   checkout_file   checkout_index   clone   commit   commit_all   commit_tree   config   current_branch   diff   dir   each_conflict   fetch   gblob   gc   gcommit   grep   gtree   index   init   lib   log   ls_files   ls_tree   merge   new   object   open   pull   push   read_tree   remote   remotes   remove   repack   repo   repo_size   reset   reset_hard   revparse   set_index   set_working   status   tag   tags   update_ref   with_index   with_temp_index   with_temp_working   with_working   write_and_commit_tree   write_tree  

Public Class methods

opens a bare Git Repository - no working directory options

clones a git repository locally

 repository - http://repo.or.cz/w/sinatra.git
 name - sinatra

options:

  :repository

   :bare
  or
   :working_directory
   :index_file

initializes a git repository

options:

 :repository
 :index_file

opens a new Git Project from a working directory you can specify non-standard git_dir and index file in the options

Public Instance methods

adds files from the working directory to the git repository

adds a new remote to this repository url can be a git url or a Git::Base object if it‘s a local reference

 @git.add_remote('scotts_git', 'git://repo.or.cz/rubygit.git')
 @git.fetch('scotts_git')
 @git.merge('scotts_git/master')

creates a new git tag (Git::Tag)

creates an archive file of the given tree-ish

returns a Git::Branches object of all the Git::Branch objects for this repo

changes current working directory for a block to the git working directory

example

 @git.chdir do
   # write files
   @git.add
   @git.commit('message')
 end

checks out a branch as the new git working directory

checks out an old version of a file

commits all pending changes in the index file to the git repository

commits all pending changes in the index file to the git repository, but automatically adds all modified files without having to explicitly calling @git.add() on them.

g.config(‘user.name’, ‘Scott Chacon’) # sets value g.config(‘user.email’, ‘email@email.com’) # sets value g.config(‘user.name’) # returns ‘Scott Chacon’ g.config # returns whole config hash

returns the name of the branch the working directory is currently on

returns a reference to the working directory

 @git.dir.path
 @git.dir.writeable?

iterates over the files which are unmerged

yields file, your_version, their_version

fetches changes from a remote branch - this does not modify the working directory, it just gets the changes from the remote if there are any

will run a grep for ‘string’ on the HEAD of the git repository

to be more surgical in your grep, you can call grep() off a specific git object. for example:

 @git.object("v2.3").grep('TODO')

in any case, it returns a hash of arrays of the type:

 hsh[tree-ish] = [[line_no, match], [line_no, match2]]
 hsh[tree-ish] = [[line_no, match], [line_no, match2]]

so you might use it like this:

  @git.grep("TODO").each do |sha, arr|
    puts "in blob #{sha}:"
    arr.each do |match|
      puts "\t line #{match[0]}: '#{match[1]}'"
    end
  end

returns reference to the git index file

this is a convenience method for accessing the class that wraps all the actual ‘git’ forked system calls. At some point I hope to replace the Git::Lib class with one that uses native methods or libgit C bindings

returns a Git::Log object with count commits

merges one or more branches into the current working branch

you can specify more than one branch to merge by passing an array of branches

returns a Git::Object of the appropriate type you can also call @git.gtree(‘tree’), but that‘s just for readability. If you call @git.gtree(‘HEAD’) it will still return a Git::Object::Commit object.

@git.object calls a factory method that will run a rev-parse on the objectish and determine the type of the object and return an appropriate object for that type

fetches a branch from a remote and merges it into the current working branch

pushes changes to a remote repository - easiest if this is a cloned repository, otherwise you may have to run something like this first to setup the push parameters:

 @git.config('remote.remote-name.push', 'refs/heads/master:refs/heads/master')

returns an array of Git:Remote objects

removes file(s) from the git repository

repacks the repository

returns reference to the git repository directory

 @git.dir.path

returns the repository size in bytes

resets the working directory to the provided commitish

resets the working directory to the commitish with ’—hard‘

runs git rev-parse to convert the objectish to a full sha

  @git.revparse("HEAD^^")
  @git.revparse('v2.4^{tree}')
  @git.revparse('v2.4:/doc/index.html')

returns a Git::Tag object

returns an array of all Git::Tag objects for this repository

LOWER LEVEL INDEX OPERATIONS ##

[Validate]