Git::Raw::Repository - Git repository class
version 0.29
use Git::Raw; # clone a Git repository my $url = 'git://github.com/ghedo/p5-Git-Raw.git'; my $repo = Git::Raw::Repository -> clone($url, 'p5-Git-Raw', { }); # print all the tags of the repository foreach my $tag (@{ $repo -> tags }) { say $tag -> name; }
A Git::Raw::Repository represents a Git repository.
Git::Raw::Repository
WARNING: The API of this module is unstable and may change without warning (any change will be appropriately documented in the changelog).
Initialize a new repository at $path.
$path
Clone the repository at $url to $path. Valid fields for the %opts hash are:
$url
%opts
"bare"
If true (default is false) create a bare repository.
"cred_acquire"
The callback to be called any time authentication is required to connect to the remote repository. The callback receives a string containing the URL of the remote, and it must return a Git::Raw::Cred object.
Open the repository at $path.
Discover the path to the repository directory given a subdirectory.
Retrieve the default Git::Raw::Config of the repository.
Retrieve the default Git::Raw::Index of the repository.
Retrieve the Git::Raw::Reference pointed by the HEAD of the repository. If the Git::Raw::Reference $new_head is passed, the HEAD of the repository will be changed to point to it.
$new_head
Retrieve the object corresponding to $id.
$id
Updates the files in the index and working tree to match the content of $object. Valid fields for the %opts hash are:
$object
"checkout_strategy"
Hash representing the desired checkout strategy. Valid fields are:
"none"
Dry-run checkout strategy. It doesn't make any changes, but checks for conflicts.
"force"
Take any action to make the working directory match the target (pretty much the opposite of "none".
"safe"
Make only modifications that will not lose changes (to be used in order to simulate git checkout.
git checkout
"safe_create"
Like "safe", but will also cause a file to be checked out if it is missing from the working directory even if it is not modified between the target and baseline (to be used in order to simulate git checkout-index and git clone).
git checkout-index
git clone
"allow_conflicts"
Apply safe updates even if there are conflicts.
"remove_untracked"
Remove untracked files from the working directory.
"remove_ignored"
Remove ignored files from the working directory.
"update_only"
Only update files that already exists (files won't be created not deleted).
"dont_update_index"
Do not write the updated files' info to the index.
"no_refresh"
Do not reload the index and git attrs from disk before operations.
"skip_unmerged"
Skip files with unmerged index entries, instead of treating them as conflicts.
Example:
$repo -> checkout($repo -> head -> target, { 'checkout_strategy' => { 'safe' => 1 } });
Reset the current HEAD to the given commit. Valid reset types are: "soft" (the head will be moved to the commit) or "mixed" (trigger a soft reset and replace the index with the content of the commit tree).
"soft"
"mixed"
Retrieve the status of <$file> in the working directory. This functions returns a list of status flags. Possible status flags are: "index_new", "index_modified", "index_deleted", "worktree_new", "worktree_modified", "worktree_deleted" and "ignored".
"index_new"
"index_modified"
"index_deleted"
"worktree_new"
"worktree_modified"
"worktree_deleted"
"ignored"
Add an ignore rules to the repository. The format of the rules is the same one of the .gitignore file (see the gitignore(5) manpage). Example:
.gitignore
gitignore(5)
$repo -> ignore("*.o\n");
Compute the Git::Raw::Diff between the given Git::Raw::Tree and the repo default index. If no $tree is passed, the diff will be computed between the repo index and the working directory.
$tree
Create a new Git::Raw::Blob. Shortcut for Git::Raw::Blob->create().
Git::Raw::Blob->create()
Create a new Git::Raw::Branch. Shortcut for Git::Raw::Branch->create().
Git::Raw::Branch->create()
Retrieve a list of Git::Raw::Branch objects.
Create a new Git::Raw::Commit. Shortcut for Git::Raw::Commit->create().
Git::Raw::Commit->create()
Create a new Git::Raw::Tag. Shortcut for Git::Raw::Tag->create().
Git::Raw::Tag->create()
Retrieve the list of Git::Raw::Tag objects.
Save the local modifications to a new stash. Shortcut for Git::Raw::Stash->save().
Git::Raw::Stash->save()
Retrieve the list of Git::Raw::Remote objects.
Retrieve the list of Git::Raw::Reference objects.
Create a new Git::Raw::Walker. Shortcut for Git::Raw::Walker->create().
Git::Raw::Walker->create()
Retrieve the complete path of the repository.
Retrieve the working directory of the repository. If $new_dir is passed, the working directory of the repository will be set to the directory.
$new_dir
Check if the repository is empty.
Check if the repository is bare.
Alessandro Ghedini <alexbio@cpan.org>
Copyright 2012 Alessandro Ghedini.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Git::Raw, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Git::Raw
CPAN shell
perl -MCPAN -e shell install Git::Raw
For more information on module installation, please visit the detailed CPAN module installation guide.