-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
377 lines (308 loc) · 16.7 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
options(width = 100)
Sys.setlocale("LC_COLLATE", "en_US.UTF-8") # ensure common sorting envir
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
ver <- desc::desc_get_version(".")
ver <- paste0("https://img.shields.io/badge/Version-", ver,
"-success.svg?style=flat&logo=github")
```
# gitr
<!-- badges: start -->
![GitHub version](`r ver`)
[![CRAN status](http://www.r-pkg.org/badges/version/gitr)](https://cran.r-project.org/package=gitr)
[![R-CMD-check](https://github.com/stufield/gitr/workflows/R-CMD-check/badge.svg)](https://github.com/stufield/gitr/actions)
[![](https://cranlogs.r-pkg.org/badges/grand-total/gitr)](https://cran.r-project.org/package=gitr)
[![Codecov test coverage](https://codecov.io/gh/stufield/gitr/branch/main/graph/badge.svg)](https://app.codecov.io/gh/stufield/gitr?branch=main)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://choosealicense.com/licenses/mit/)
<!-- badges: end -->
A light-weight, dependency-free, application programming interface
(API) to access system-level [Git](https://git-scm.com/downloads) commands from within `R`.
Contains wrappers and defaults for common data science workflows as well as
[Zsh](https://github.com/ohmyzsh/ohmyzsh) plugin aliases (see below).
A generalized API syntax is also available.
A system installation of [Git](https://git-scm.com/downloads) is required.
If you run into any issues/problems with `gitr` full documentation
of the most recent
[release](https://github.com/stufield/gitr/releases)
can be found at the
[pkgdown website](https://stufield.github.io/gitr/).
If the issue persists I encourage you to consult the
[issues](https://github.com/stufield/gitr/issues/)
page and, if appropriate, submit an issue and/or feature request.
## Disclaimer
Use at own risk :smiley_cat:, however, PRs are encouraged for ideas that I've missed.
The functionality contained in `gitr` are _heavily_ influenced by __my__
personal data science workflows and may not suit all users.
However, if you have an idea that would make the package better,
more widely usable, and/or efficient, please submit an
[issue](https://github.com/stufield/gitr/issues/)
or
[pull request](https://github.com/stufield/gitr/pulls/).
## Installing
The easiest way to install `gitr` is to install directly from
[CRAN](https://cran.r-project.org/web/packages/gitr/index.html):
```{r install-cran, eval = FALSE}
install.packages("gitr")
```
Alternatively install the development version from GitHub:
```{r install-gh, eval = FALSE}
remotes::install_github("stufield/gitr")
```
To install a _specific_ tagged release, use:
```{r install-version, eval = FALSE}
remotes::install_github("stufield/gitr@v0.0.1")
```
-----------
## Loading
```{r load}
library(gitr)
```
## Examples
Here are some basic examples of the functionality grouped by common
actions:
#### Basics
```{r ver}
git_version()
```
```{r current}
git_current_br()
```
```{r default}
git_default_br()
```
#### The Core Engine
```{r git-core}
(git("branch", "foo"))
git("branch", "-av")$stdout |>
cat(sep = "\n")
git("branch", "-D", "foo")$stdout
```
#### Committing
```{r commit-msgs}
get_commit_msgs(n = 3)
```
```{r glog}
glog(5)
```
```{r commit-diff, eval = FALSE}
git_diffcommits()
```
```{r reset-hard, eval = FALSE}
git_reset_hard()
```
```{r reset-soft, eval = FALSE}
git_reset_soft()
```
```{r uncommit, eval = FALSE}
git_uncommit()
```
```{r unstage, eval = FALSE}
git_unstage("DESCRIPTION")
```
#### SHA1
```{r trim}
is_sha("d670c93733f3e1d7c95df7f61ebf6ca0476f14e3")
is_sha("foo")
trim_sha("d670c93733f3e1d7c95df7f61ebf6ca0476f14e3")
trim_sha("foo")
```
#### Tags
```{r tag-recent}
git_recent_tag()
```
```{r tag-info}
git_tag_info()
```
#### Situation Report
```{r sitrep}
git_sitrep()
```
--------
## ZSH-aliases available in `gitr`
| alias | git command |
| :-------------------- | :---------------------------------------- |
| `ga()` | `git add` |
| `gst()` | `git status` |
| `gss()` | `git status -s` |
| `gau()` | `git add -u` |
| `gaa()` | `git add --all` |
| `gb()` | `git branch` |
| `gba()` | `git branch -a` |
| `gbd()` | `git branch -d/-D` |
| `gdf()` | `git diff <file>` |
| `gbnm()` | `git branch --no-merged` |
| `gbmm()` | `git branch --merged` |
| `gbr()` | `git branch --remote` |
| `gac()`, `gcn` | `git commit --no-verify --no-edit --amend`|
| `gcc()` | `git commit` |
| `gco()` | `git checkout` |
| `gcb()` | `git checkout -b` |
| `gcm()` | `git checkout git_default_br()` |
| `gcf()` | `git config --list` |
| `gnuke()` | `git reset --hard && git clean -dfx` |
| `gcmsg()` | `git commit -m` |
| `gp()` | `git push` |
| `gpu()` | `git push -u` |
| `gpd()` | `git push --dry-run` |
| `gpf()` | `git push --force-with-lease` |
| `gpr()` | `git pull --rebase --autostash -v` |
| `glog()` | `git log --oneline --decorate --graph` |
| `gwip()` | `git add -u && commit --no-verify -m "wip"` |
| `gclean()` | `git clean -f -d` |
| `grm()` | `git rm` |
| `grmc()` | `git rm --cached` |
| `gsta()` | `git stash` |
| `gstl()` | `git stash list` |
| `gpop()`,`gstp()` | `git stash pop` |
| `gstaa()` | `git stash apply` |
| `gstd()` | `git stash drop` |
| `gstc()` | `git stash clear` |
| `gsts()` | `git stash show --text` |
| `gtn()` | `git tag -n` |
| `grba()` | `git rebase --abort` |
| `grbc()` | `git rebase --continue` |
| `grbs()` | `git rebase --skip` |
| `grbm()` | `git rebase git_default_br()` |
| `grv()` | `git remote -v` |
-------------
## Full list of ZSH-aliases
For general reference, here is a list of the available aliases via the
`git-plugin` from [Oh-My-Zsh](https://github.com/ohmyzsh/ohmyzsh).
See also [Oh-My-Zsh](https://ohmyz.sh) for general installation.
#### Aliases
| alias | git command |
| :--------------- | :----------------------------------------------- |
| `gapa` | `git add --patch` |
| `gav` | `git add --verbose` |
| `gloga` | `git log --oneline --decorate --graph --all` |
| `gup` | `git pull --rebase` |
| `gupv` | `git pull --rebase -v` |
| `gupa` | `git pull --rebase --autostash` |
| `gupav` | `git pull --rebase --autostash -v` |
| `gap` | `git apply` |
| `gapt` | `git apply --3way` |
| `gbda` | `git branch --no-color --merged \| command grep -vE ^([+*] \| \s*($(git_main_branch) \| $(git_develop_branch))\s*$) \| command xargs git branch -d 2>/dev/null` |
| `gbl` | `git blame -b -w` |
| `gbs` | `git bisect` |
| `gbsb` | `git bisect bad` |
| `gbsg` | `git bisect good` |
| `gbsr` | `git bisect reset` |
| `gbss` | `git bisect start` |
| `gca` | `git commit -v -a` |
| `gca!` | `git commit -v -a --amend` |
| `gcan!` | `git commit -v -a --no-edit --amend` |
| `gcans!` | `git commit -v -a -s --no-edit --amend` |
| `gcam` | `git commit -a -m` |
| `gcsm` | `git commit -s -m` |
| `gcas` | `git commit -a -s` |
| `gcasm` | `git commit -a -s -m` |
| `gcl` | `git clone --recurse-submodules` |
| `gcor` | `git checkout --recurse-submodules` |
| `gcd` | `git checkout $(git_develop_branch)` |
| `gcount` | `git shortlog -sn` |
| `gcp` | `git cherry-pick` |
| `gcpa` | `git cherry-pick --abort` |
| `gcpc` | `git cherry-pick --continue` |
| `gcs` | `git commit -S` |
| `gcss` | `git commit -S -s` |
| `gcssm` | `git commit -S -s -m` |
| `gdca` | `git diff --cached` |
| `gdcw` | `git diff --cached --word-diff` |
| `gdct` | `git describe --tags $(git rev-list --tags --max-count=1)` |
| `gds` | `git diff --staged` |
| `gdt` | `git diff-tree --no-commit-id --name-only -r` |
| `gdup` | `git diff @{upstream}` |
| `gdw` | `git diff --word-diff` |
| `gf` | `git fetch` |
| `gfo` | `git fetch origin` |
| `gfg` | `git ls-files \| grep` |
| `gg` | `git gui citool` |
| `gga` | `git gui citool --amend` |
| `ggpur` | `ggu` |
| `ggpull` | `git pull origin $(git_current_branch)` |
| `ggpush` | `git push origin $(git_current_branch)` |
| `ggsup` | `git branch --set-upstream-to=origin/$(git_current_branch)`|
| `gpsup` | `git push --set-upstream origin $(git_current_branch)` |
| `ghh` | `git help` |
| `gignore` | `git update-index --assume-unchanged` |
| `gignored` | `git ls-files -v \| grep "^[[:lower:]]"` |
| `git-svn-dcommit-push` | `git svn dcommit && git push github $(git_main_branch):svntrunk` |
| `gl` | `git pull` |
| `glg` | `git log --stat` |
| `glgp` | `git log --stat -p` |
| `glgg` | `git log --graph` |
| `glgga` | `git log --graph --decorate --all` |
| `glgm` | `git log --graph --max-count=10` |
| `glo` | `git log --oneline --decorate` |
| `glol` | `git log --graph --pretty` |
| `glols="git log --graph --pretty` | `%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --stat"`
| `glod="git log --graph --pretty` | `%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'"`
| `glods="git log --graph --pretty` | `%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset' --date=short"`
| `glola="git log --graph --pretty` | `%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --all"`
| `gm` | `git merge` |
| `gmom` | `git merge origin/$(git_main_branch)` |
| `gmtl` | `git mergetool --no-prompt` |
| `gmtlvim` | `git mergetool --no-prompt --tool=vimdiff` |
| `gmum` | `git merge upstream/$(git_main_branch)` |
| `gma` | `git merge --abort` |
| `gpf!` | `git push --force` |
| `gpoat` | `git push origin --all && git push origin --tags` |
| `gpv` | `git push -v` |
| `gr` | `git remote` |
| `gra` | `git remote add` |
| `grb` | `git rebase` |
| `grbd` | `git rebase $(git_develop_branch)` |
| `grbi` | `git rebase -i` |
| `grbo` | `git rebase --onto` |
| `grev` | `git revert` |
| `grh` | `git reset` |
| `grhh` | `git reset --hard` |
| `groh` | `git reset origin/$(git_current_branch) --hard` |
| `grmv` | `git remote rename` |
| `grrm` | `git remote remove` |
| `grs` | `git restore` |
| `grset` | `git remote set-url` |
| `grss` | `git restore --source` |
| `grst` | `git restore --staged` |
| `grt` | `cd $(git rev-parse --show-toplevel \|\| echo .)` |
| `gru` | `git reset --` |
| `grup` | `git remote update` |
| `gsb` | `git status -sb` |
| `gsd` | `git svn dcommit` |
| `gsh` | `git show` |
| `gsi` | `git submodule init` |
| `gsps` | `git show --pretty=short --show-signature` |
| `gsr` | `git svn rebase` |
| `gstu` | `gsta --include-untracked` |
| `gstall` | `git stash --all` |
| `gsu` | `git submodule update` |
| `gsw` | `git switch` |
| `gswc` | `git switch -c` |
| `gswm` | `git switch $(git_main_branch)` |
| `gswd` | `git switch $(git_develop_branch)` |
| `gts` | `git tag -s` |
| `gtv` | `git tag \| sort -V` |
| `gtl` | `gtl(){ git tag --sort=-v:refname -n -l ${1}* }; noglob gtl` |
| `gunignore` | `git update-index --no-assume-unchanged` |
| `gunwip` | `git log -n 1 \| grep -q -c "\-\-wip\-\-" && git reset HEAD~1` |
| `glum` | `git pull upstream $(git_main_branch)` |
| `gwch` | `git whatchanged -p --abbrev-commit --pretty=medium` |
| `gam` | `git am` |
| `gamc` | `git am --continue` |
| `gams` | `git am --skip` |
| `gama` | `git am --abort` |
| `gamscp` | `git am --show-current-patch` |
#### LICENSE
Please note that this package is released with
a [LICENSE](https://github.com/stufield/gitr/blob/main/LICENSE.md).
By using in this package you agree to abide by its terms.