git2r: Provides Access to Git Repositories
Gitリポジトリへのアクセス
- CRAN: http://cran.r-project.org/web/packages/git2r/index.html
- GitHub: https://github.com/ropensci/git2r
> library(git2r)
> repo <- repository("~/git/rpkg_showcase/")
バージョン: 0.15.0
関数名 | 概略 |
---|---|
[,git_tree,integer,missing-method |
Extract object from tree |
add |
Add file(s) to index |
ahead_behind |
Ahead Behind |
blame |
Get blame for file |
blob_create |
Create blob from file on disk |
branch_create |
Create a branch |
branch_delete |
Delete a branch |
branch_get_upstream |
Get remote tracking branch |
branch_remote_name |
Remote name of a branch |
branch_remote_url |
Remote url of a branch |
branch_rename |
Rename a branch |
branch_set_upstream |
Set remote tracking branch |
branch_target |
Get target (sha) pointed to by a branch |
branches |
Branches |
bundle_r_package |
Bundle bare repo of package |
checkout |
Checkout |
clone |
Clone a remote repository |
coerce-git_repository-method |
Coerce Git repository to a 'data.frame' |
coerce-git_tree-data.frame-method |
Coerce entries in a git_tree to a 'data.frame' |
coerce-git_tree-list-method |
Coerce entries in a git_tree to a list of entry objects |
commit |
Commit |
commits |
Commits |
config |
Config |
content |
Content of blob |
contributions |
Contributions |
cred_env |
Create a new environmental credential object |
cred_env-class |
S4 class to handle environmental variables credential object |
cred_ssh_key |
Create a new passphrase-protected ssh key credential object |
cred_ssh_key-class |
S4 class to handle a passphrase-protected ssh key credential object |
cred_token |
Create a new personal access token credential object |
cred_token-class |
S4 class to handle a personal access token credential object |
cred_user_pass |
Create a new plain-text username and password credential object |
cred_user_pass-class |
S4 class to handle plain-text username and password credential object |
default_signature |
Get the signature |
descendant_of |
Descendant diff,git_repository-method Changes between commits, trees, working tree, etc. |
discover_repository |
Find path to repository for any file |
fetch |
Fetch new data and update tips |
fetch_heads |
Get updated heads during the last fetch. |
git2r |
git2r: R bindings to the libgit2 library |
git_blame-class |
S4 class to handle a git blame for a single file |
git_blame_hunk-class |
S4 class to represent a blame hunk |
git_blob-class |
S4 class to handle a git blob |
git_branch-class |
S4 class to handle a git branch |
git_commit-class |
S4 class to handle a git commit. |
git_diff-class |
Git diff |
git_diff_file-class |
Git diff file |
git_diff_hunk-class |
Git diff hunk |
git_diff_line-class |
Git diff line |
git_fetch_head-class |
S4 class to handle a fetch head |
git_merge_result-class |
S4 class to handle the merge result |
git_note-class |
S4 class to handle a git note |
git_reference-class |
S4 class to handle a git reference |
git_reflog_entry-class |
S4 class to handle a git reflog entry. |
git_repository-class |
S4 class to handle a git repository |
git_signature-class |
S4 class to handle a git signature |
git_stash-class |
S4 class to handle a git stash |
git_tag-class |
S4 class to handle a git tag |
git_time-class |
S4 class to handle a git time in a signature |
git_transfer_progress-class |
Class '"git_transfer_progress"' |
git_tree-class |
S4 class to handle a git tree |
hash |
Determine the sha from a blob string |
hashfile |
Determine the sha from a blob in a file |
head,git_repository-method |
Get HEAD for a repository |
in_repository |
Determine if a directory is in a git repository |
init |
Init a repository |
is_bare |
Check if repository is bare |
is_binary |
Is blob binary |
is_blob |
Check if object is S4 class git_blob |
is_commit |
Check if object is S4 class git_commit |
is_detached |
Check if HEAD of repository is detached |
is_empty |
Check if repository is empty |
is_head |
Check if branch is head |
is_local |
Check if branch is local |
is_merge |
Is merge |
is_shallow |
Determine if the repository was a shallow clone |
length,git_blob-method |
Size in bytes of the contents of a blob |
length,git_diff-method |
Number of files in git_diff object |
length,git_tree-method |
Number of entries in tree |
libgit2_features |
Compile time options for libgit2. |
libgit2_sha |
SHA of the libgit2 library |
libgit2_version |
Version of the libgit2 library |
lookup |
Lookup |
merge,git_repository,character-method |
Merge a branch into HEAD |
merge_base |
Find a merge base between two commits |
note_create |
Add note for a object |
note_default_ref |
Default notes reference |
note_remove |
Remove the note for an object |
notes |
List notes |
odb_blobs |
Blobs in the object database |
odb_objects |
List all objects available in the database |
parents |
Parents |
plot,git_repository-method |
Plot commits over time |
pull |
Pull |
punch_card |
Punch card |
push |
Push |
references |
Get all references that can be found in a repository. |
reflog |
List and view reflog information |
remote_add |
Add a remote to a repo |
remote_ls |
List references in a remote repository |
remote_remove |
Remove a remote |
remote_rename |
Rename a remote |
remote_set_url |
Set the remote's url in the configuration |
remote_url |
Get the remote url for remotes in a repo |
remotes |
Get the configured remotes for a repo |
repository |
Open a repository |
reset |
Reset current HEAD to the specified state |
revparse_single |
Revparse |
rm_file |
Remove files from the working tree and from the index |
show,git_blob-method |
Brief summary of blob |
show,git_branch-method |
Brief summary of branch |
show,git_commit-method |
Brief summary of commit |
show,git_diff-method |
Show a diff |
show,git_merge_result-method |
Brief summary of merge result |
show,git_note-method |
Brief summary of note |
show,git_reference-method |
Brief summary of reference |
show,git_reflog_entry-method |
Brief summary of a reflog entry |
show,git_repository-method |
Brief summary of repository |
show,git_signature-method |
Brief summary of signature |
show,git_stash-method |
Brief summary of a stash |
show,git_tag-method |
Brief summary of a tag |
show,git_time-method |
Brief summary of 'git_time' |
show,git_tree-method |
Brief summary of tree |
ssl_cert_locations |
Set the SSL certificate-authority locations |
stash |
Stash |
stash_drop |
Drop stash |
stash_list |
List stashes in repository |
status |
Status |
summary,git_blob-method |
Summary of blob |
summary,git_commit-method |
Summary of commit |
summary,git_diff-method |
Show the summary of a diff |
summary,git_repository-method |
Summary of repository |
summary,git_stash-method |
Summary of a stash |
summary,git_tag-method |
Summary of a tag |
summary,git_tree-method |
Summary of tree |
tag |
Create tag targeting HEAD commit in repository |
tags |
Tags |
tree |
Tree |
when |
When |
workdir |
Workdir of repository |
add
ファイルをインデックスに追加する
Arguments
- repo
- path
- ...
- force
> # git add
> add(repo, path, ...)
branches
リポジトリのブランチを表示する
Arguments
- repo
- flags... ブランチの参照先を指定する。
all
,local
,remote
> branches(repo, flags = "local")
$master
[376daa] (Local) (HEAD) master
> branches(repo, flags = "remote")
$`origin/gh-pages`
[06ee39] (origin @ https://github.com/uribo/rpkg_showcase.git) gh-pages
$`origin/master`
[436627] (origin @ https://github.com/uribo/rpkg_showcase.git) master
branch_create
ブランチを作成する
Arguments
- commit
- name
- force
> commit_1 <- commit(repo, "First commit message")
> branch_create(commit = commit_1, name = "test-branch", force = FALSE)
branch_delete
ブランチを削除する
> branch_delete(branch)
branch_get_upstream
(リモートの)追跡ブランチを表示する
> head(repo) %>% branch_get_upstream()
Error in x[seq_len(n)]: object of type 'S4' is not subsettable
branch_remote_name
> branches(repo)[[3]] %>% branch_remote_name()
[1] "origin"
branch_remote_url
リモートブランチのURL
> head(repo) %>% branch_get_upstream() %>% branch_remote_url()
Error in x[seq_len(n)]: object of type 'S4' is not subsettable
branch_set_upstream
追跡ブランチを設定する
> head(repo) %>% branch_set_upstream(name = "origin/master")
clone
リモートリポジトリのクローン
Arguments
- url
- local_path
- bare
- branch
- credentials
- progress
> clone(url, local_path, bare = FALSE, branch = NULL, credentials = NULL,
+ progress = TRUE)
config
> config(repo = NULL, global = FALSE, user.name, user.email, ...)
commit
コミットを行う
Arguments
- repo
- message
- all
- session
- reference
- author
- committer
> commit(repo, message = NULL, all = FALSE, session = FALSE,
+ reference = "HEAD", author = default_signature(repo),
+ committer = default_signature(repo))
diff
> git2r::diff
standardGeneric for "diff" defined from package "base"
function (x, ...)
standardGeneric("diff")
<environment: 0x1058ae230>
Methods may be defined for arguments: x
Use showMethods("diff") for currently available ones.
init
リポジトリの初期化
Arguments
- path... リポジトリを作成するパス
- bare... ベアリポジトリとするかどうか。ベアリポジトリには作業ファイルは存在せず、管理ファイルのみのリポジトリとなる
> init(path, bare = FALSE)
punch_card
活動に基づいたパンチカードをプロットする
> punch_card(repo)
remotes
> remotes(repo)
[1] "origin"
repository
リポジトリを開く。返り値はS4クラスのgit_repositoryオブジェクト
> repository("~/git/rpkg_showcase/") %>% {
+ print(.)
+ class(.)
+ }
Local: master /Users/uri/git/rpkg_showcase/
Remote: master @ origin (https://github.com/uribo/rpkg_showcase.git)
Head: [376daa1] 2015-09-19: change
[1] "git_repository"
attr(,"package")
[1] "git2r"
rm_file
Arguments
- repo
- path
> rm_file(repo, path)
status
作業ディレクトリのファイルのステージ状態を確認する
> status(repo,
+ staged = TRUE,
+ unstaged = TRUE,
+ untracked = TRUE,
+ ignored = FALSE) %>%
+ attributes()
$names
[1] "staged" "unstaged" "untracked"
$class
[1] "git_status"
summary
> git2r::summary(repo)
Local: master /Users/uri/git/rpkg_showcase/
Remote: master @ origin (https://github.com/uribo/rpkg_showcase.git)
Head: [376daa1] 2015-09-19: change
Branches: 3
Tags: 0
Commits: 5
Contributors: 1
Stashes: 0
Ignored files: 13
Untracked files: 524
Unstaged files: 19
Staged files: 0
Latest commits:
[376daa1] 2015-09-19: change
[ae39e96] 2015-09-19: change
[436627e] 2015-05-12: [ADD]great packages :package:
[2f4a0bf] 2015-05-12: [UPGRADE]add .md
[35c3f1c] 2015-05-11: [ADD]initial commit :hatching_chick:
tag
tagの作成
Arguments
- object
- name
- message
- session
- tagger
> tag(repo, name = "Tagname", message = "Tag message")
tags
リポジトリ内のタグを取得する
> tags(repo)
<condition: >
tree
when
workdir
ベアリポジトリの場合はNULLが返る
> workdir(repo)
[1] "/Users/uri/git/rpkg_showcase/"