CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Thu, 24 Jul 2025 06:14:30 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20090906080813
location: https://web.archive.org/web/20090906080813/https://github.com/schacon/ruby-git/tree/master
server-timing: captures_list;dur=0.574945, exclusion.robots;dur=0.022149, exclusion.robots.policy;dur=0.010954, esindex;dur=0.010269, cdx.remote;dur=224.041944, LoadShardBlock;dur=259.382324, PetaboxLoader3.datanode;dur=98.858550, PetaboxLoader3.resolve;dur=75.749701
x-app-server: wwwb-app210
x-ts: 302
x-tr: 514
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: SERVER=wwwb-app210; path=/
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Thu, 24 Jul 2025 06:14:31 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.6.31
x-archive-orig-date: Sun, 06 Sep 2009 08:08:12 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "bcabf931fd00077f4c81f2ffe28d4ca9"
x-archive-orig-x-runtime: 237ms
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-orig-content-length: 35843
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Sun, 06 Sep 2009 08:08:13 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate", ; rel="first memento"; datetime="Tue, 05 Feb 2008 16:27:04 GMT", ; rel="prev memento"; datetime="Thu, 20 Aug 2009 03:06:26 GMT", ; rel="memento"; datetime="Sun, 06 Sep 2009 08:08:13 GMT", ; rel="next memento"; datetime="Fri, 19 Jul 2013 02:50:27 GMT", ; rel="last memento"; datetime="Mon, 05 Feb 2024 01:50:07 GMT"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 51_11_20090906000237_crawl101.gpg-c/51_11_20090906080717_crawl101.arc.gz
server-timing: captures_list;dur=0.480484, exclusion.robots;dur=0.019392, exclusion.robots.policy;dur=0.008816, esindex;dur=0.009602, cdx.remote;dur=5.974393, LoadShardBlock;dur=396.487912, PetaboxLoader3.resolve;dur=335.750794, PetaboxLoader3.datanode;dur=162.072022, load_resource;dur=126.436785
x-app-server: wwwb-app210
x-ts: 200
x-tr: 604
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
x-location: All
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
schacon's ruby-git at master - GitHub
This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (

This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (

Run the following if you haven't already:
gem sources -a https://gems.github.com
Install the gem(s):
sudo gem install schacon-git
Description: | Ruby/Git is a Ruby library that can be used to create, read and manipulate Git repositories by wrapping system calls to the git binary. edit |
Homepage: | edit |
Public Clone URL: |
git://github.com/schacon/ruby-git.git
Give this clone URL to anyone.
git clone git://github.com/schacon/ruby-git.git
|
Your Clone URL: |
Use this clone URL yourself.
git clone git@github.com:schacon/ruby-git.git
|
ruby-git /
README
== Git Library for Ruby Library for using Git in Ruby. Test. = Homepage Git public hosting of the project source code is at: https://github/schacon/ruby-git = Install You can install Ruby/Git like this: $ sudo gem install schacon-git --source=https://gems.github.com = Major Objects Git::Base - this is the object returned from a Git.open or Git.clone. Most major actions are called from this object. Git::Object - this is the base object for your tree, blob and commit objects, returned from @git.gtree or @git.object calls. the Git::AbstractObject will have most of the calls in common for all those objects. Git::Diff - returns from a @git.diff command. It is an Enumerable that returns Git::Diff:DiffFile objects from which you can get per file patches and insertion/deletion statistics. You can also get total statistics from the Git::Diff object directly. Git::Status - returns from a @git.status command. It is an Enumerable that returns Git:Status::StatusFile objects for each object in git, which includes files in the working directory, in the index and in the repository. Similar to running 'git status' on the command line to determine untracked and changed files. Git::Branches - Enumerable object that holds Git::Branch objects. You can call .local or .remote on it to filter to just your local or remote branches. Git::Remote - A reference to a remote repository that is tracked by this repository. Git::Log - An Enumerable object that references all the Git::Object::Commit objects that encompass your log query, which can be constructed through methods on the Git::Log object, like: @git.log(20).object("some_file").since("2 weeks ago").between('v2.6', 'v2.7').each { |commit| [block] } = Examples Here are a bunch of examples of how to use the Ruby/Git package. First you have to remember to require rubygems if it's not. Then include the 'git' gem. require 'rubygems' require 'git' Here are the operations that need read permission only. g = Git.open (working_dir, :log => Logger.new(STDOUT)) g.index g.index.readable? g.index.writable? g.repo g.dir g.log # returns array of Git::Commit objects g.log.since('2 weeks ago') g.log.between('v2.5', 'v2.6') g.log.each {|l| puts l.sha } g.gblob('v2.5:Makefile').log.since('2 weeks ago') g.object('HEAD^').to_s # git show / git rev-parse g.object('HEAD^').contents g.object('v2.5:Makefile').size g.object('v2.5:Makefile').sha g.gtree(treeish) g.gblob(treeish) g.gcommit(treeish) commit = g.gcommit('1cc8667014381') commit.gtree commit.parent.sha commit.parents.size commit.author.name commit.author.email commit.author.date.strftime("%m-%d-%y") commit.committer.name commit.date.strftime("%m-%d-%y") commit.message tree = g.gtree("HEAD^{tree}") tree.blobs tree.subtrees tree.children # blobs and subtrees g.revparse('v2.5:Makefile') g.branches # returns Git::Branch objects g.branches.local g.branches.remote g.branches[:master].gcommit g.branches['origin/master'].gcommit g.grep('hello') # implies HEAD g.blob('v2.5:Makefile').grep('hello') g.tag('v2.5').grep('hello', 'docs/') g.diff(commit1, commit2).size g.diff(commit1, commit2).stats g.gtree('v2.5').diff('v2.6').insertions g.diff('gitsearch1', 'v2.5').path('lib/') g.diff('gitsearch1', @git.gtree('v2.5')) g.diff('gitsearch1', 'v2.5').path('docs/').patch g.gtree('v2.5').diff('v2.6').patch g.gtree('v2.5').diff('v2.6').each do |file_diff| puts file_diff.path puts file_diff.patch puts file_diff.blob(:src).contents end g.config('user.name') # returns 'Scott Chacon' g.config # returns whole config hash g.tag # returns array of Git::Tag objects And here are the operations that will need to write to your git repository. g = Git.init Git.init('project') Git.init('/home/schacon/proj', { :git_dir => '/opt/git/proj.git', :index_file => '/tmp/index'} ) g = Git.clone(URI, :name => 'name', :path => '/tmp/checkout') g.config('user.name', 'Scott Chacon') g.config('user.email', 'email@email.com') g.add('.') g.add([file1, file2]) g.remove('file.txt') g.remove(['file.txt', 'file2.txt']) g.commit('message') g.commit_all('message') g = Git.clone(repo, 'myrepo') g.chdir do new_file('test-file', 'blahblahblah') g.status.changed.each do |file| puts file.blob(:index).contents end end g.reset # defaults to HEAD g.reset_hard(Git::Commit) g.branch('new_branch') # creates new or fetches existing g.branch('new_branch').checkout g.branch('new_branch').delete g.branch('existing_branch').checkout g.checkout('new_branch') g.checkout(g.branch('new_branch')) g.branch(name).merge(branch2) g.branch(branch2).merge # merges HEAD with branch2 g.branch(name).in_branch(message) { # add files } # auto-commits g.merge('new_branch') g.merge('origin/remote_branch') g.merge(b.branch('master')) g.merge([branch1, branch2]) r = g.add_remote(name, uri) # Git::Remote r = g.add_remote(name, Git::Base) # Git::Remote g.remotes # array of Git::Remotes g.remote(name).fetch g.remote(name).remove g.remote(name).merge g.remote(name).merge(branch) g.fetch g.fetch(g.remotes.first) g.pull g.pull(Git::Repo, Git::Branch) # fetch and a merge g.add_tag('tag_name') # returns Git::Tag g.repack g.push g.push(g.remote('name')) Some examples of more low-level index and tree operations g.with_temp_index do g.read_tree(tree3) # calls self.index.read_tree g.read_tree(tree1, :prefix => 'hi/') c = g.commit_tree('message') # or # t = g.write_tree c = g.commit_tree(t, :message => 'message', :parents => [sha1, sha2]) g.branch('branch_name').update_ref(c) g.update_ref(branch, c) g.with_temp_working do # new blank working directory g.checkout g.checkout(another_index) g.commit # commits to temp_index end end g.set_index('/path/to/index') g.with_index(path) do # calls set_index, then switches back after end g.with_working(dir) do # calls set_working, then switches back after end g.with_temp_working(dir) do g.checkout_index(:prefix => dir, :path_limiter => path) # do file work g.commit # commits to index end
This feature is coming soon. Sit tight!