mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
feat: Implement git-get command (#1045)
* feat: Add `git-get` command * Update Commands.md Co-authored-by: 罗泽轩 <spacewanderlzx@gmail.com> * fix: Use Git config to store value * improve `git-get` description * fix: Add `--global` to git invocation * Enable passing options to `git clone` * fix: Ordering of checks --------- Co-authored-by: 罗泽轩 <spacewanderlzx@gmail.com>
This commit is contained in:
parent
34609bd800
commit
8af43892f6
10
Commands.md
10
Commands.md
|
|
@ -28,6 +28,7 @@
|
|||
- [`git force-clone`](#git-force-clone)
|
||||
- [`git fork`](#git-fork)
|
||||
- [`git fresh-branch`](#git-fresh-branch)
|
||||
- [`git get`](#git-get)
|
||||
- [`git gh-pages`](#git-gh-pages)
|
||||
- [`git graft`](#git-graft)
|
||||
- [`git guilt`](#git-guilt)
|
||||
|
|
@ -889,6 +890,15 @@ Create empty local branch `docs`:
|
|||
$ git fresh-branch docs
|
||||
```
|
||||
|
||||
## git get
|
||||
|
||||
Clone repository into a subdirectory of the configured path, `"$HOME/some-dir"`:
|
||||
|
||||
```bash
|
||||
$ git config --global --add git-extras.get.clone-path "$HOME/some-dir"
|
||||
$ git get 'https://github.com/hyperupcall/bake'
|
||||
```
|
||||
|
||||
## git guilt
|
||||
|
||||
Calculate the change in blame between two revisions
|
||||
|
|
|
|||
40
bin/git-get
Executable file
40
bin/git-get
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
_usage() {
|
||||
printf '%s\n' "usage: ${0##*/} <url>
|
||||
usage: ${0##*/} --help
|
||||
|
||||
Clone a repository in a particular directory."
|
||||
}
|
||||
|
||||
if (( $# == 0 )); then
|
||||
_usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for arg; do
|
||||
if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then
|
||||
_usage
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
url=$1
|
||||
if ! shift; then
|
||||
printf 'ERROR: Failed to shift' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
clone_path=$(git config --get git-extras.get.clone-path)
|
||||
|
||||
if [ -z "$clone_path" ]; then
|
||||
printf 'ERROR: %s\n' "Git configuration key 'git-extras.get.clone-path' must be set to a directory to clone under" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dirname=${url%/}
|
||||
dirname=${url%.git}
|
||||
dirname=${dirname##*/}
|
||||
|
||||
mkdir -p "$clone_path"
|
||||
git clone "$url" "$clone_path/$dirname" "$@"
|
||||
|
|
@ -373,6 +373,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \
|
|||
force-clone:'overwrite local repositories with clone' \
|
||||
fork:'fork a repo on GitHub' \
|
||||
fresh-branch:'create fresh branches' \
|
||||
get:'clone a repository in a directory' \
|
||||
gh-pages:'create the GitHub pages branch' \
|
||||
graft:'merge and destroy a given branch' \
|
||||
guilt:'calculate change between two revisions' \
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ set __fish_git_extras_commands \
|
|||
"force-clone:overwrite local repositories with clone" \
|
||||
"fork:Fork a repo on github" \
|
||||
"fresh-branch:Create fresh branches" \
|
||||
"get:Clone a repository in a directory" \
|
||||
"gh-pages:Create the GitHub Pages branch" \
|
||||
"graft:Merge and destroy a given branch" \
|
||||
"guilt:calculate change between two revisions" \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.\" generated with Ronn-NG/v0.9.1
|
||||
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
||||
.TH "GIT\-EXTRAS" "1" "December 2021" "" "Git Extras"
|
||||
.TH "GIT\-EXTRAS" "1" "May 2023" "" "Git Extras"
|
||||
.SH "NAME"
|
||||
\fBgit\-extras\fR \- Awesome GIT utilities
|
||||
.SH "SYNOPSIS"
|
||||
|
|
@ -20,7 +20,7 @@ Self update\.
|
|||
.SH "ENVIRONMENT AND CONFIGURATION VARIABLES"
|
||||
\fBgit config \-\-add git\-extras\.default\-branch $BRANCH\fR
|
||||
.P
|
||||
Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\fR isn\'t set, \fBinit\.defaultBranch\fR is used instead\. If none of them are set it defaults to \fBmain\fR\.
|
||||
Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\fR isn't set, \fBinit\.defaultBranch\fR is used instead\. If none of them are set it defaults to \fBmain\fR\.
|
||||
.SH "COMMANDS"
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-abort(1)\fR Abort current git operation
|
||||
|
|
@ -31,6 +31,8 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
|
|||
.IP "\[ci]" 4
|
||||
\fBgit\-authors(1)\fR Generate authors report
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-browse\-ci(1)\fR \fIView the web page for the current repository\fR
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-browse(1)\fR \fIView the web page for the current repository\fR
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-brv(1)\fR List branches sorted by their last commit date
|
||||
|
|
@ -47,7 +49,7 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
|
|||
.IP "\[ci]" 4
|
||||
\fBgit\-commits\-since(1)\fR Show commit logs since some date
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-contrib(1)\fR Show user\'s contributions
|
||||
\fBgit\-contrib(1)\fR Show user's contributions
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-count(1)\fR Show commit count
|
||||
.IP "\[ci]" 4
|
||||
|
|
@ -77,6 +79,8 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
|
|||
.IP "\[ci]" 4
|
||||
\fBgit\-fresh\-branch(1)\fR Create fresh branches
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-get(1)\fR Clone a Git repository under a configured directory
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-gh\-pages(1)\fR Create the GitHub Pages branch
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-graft(1)\fR Merge and destroy a given branch
|
||||
|
|
@ -115,7 +119,7 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
|
|||
.IP "\[ci]" 4
|
||||
\fBgit\-pull\-request(1)\fR Create pull request for GitHub project
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-reauthor(1)\fR Rewrite history to change author\'s identity
|
||||
\fBgit\-reauthor(1)\fR Rewrite history to change author's identity
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-rebase\-patch(1)\fR Rebases a patch
|
||||
.IP "\[ci]" 4
|
||||
|
|
@ -145,7 +149,7 @@ Change the default branch to \fB$BRANCH\fR\. If \fBgit\-extras\.default\-branch\
|
|||
.IP "\[ci]" 4
|
||||
\fBgit\-show\-unmerged\-branches(1)\fR Show unmerged branches
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-squash(1)\fR squash N last changes up to a ref\'ed commit
|
||||
\fBgit\-squash(1)\fR squash N last changes up to a ref'ed commit
|
||||
.IP "\[ci]" 4
|
||||
\fBgit\-stamp(1)\fR Stamp the last commit message
|
||||
.IP "\[ci]" 4
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@
|
|||
<li>
|
||||
<strong><a class="man-ref" href="git-authors.html">git-authors<span class="s">(1)</span></a></strong> Generate authors report</li>
|
||||
<li>
|
||||
<strong><a class="man-ref" href="git-browse-ci.html">git-browse-ci<span class="s">(1)</span></a></strong> <var>View the web page for the current repository</var>
|
||||
</li>
|
||||
<li>
|
||||
<strong><a class="man-ref" href="git-browse.html">git-browse<span class="s">(1)</span></a></strong> <var>View the web page for the current repository</var>
|
||||
</li>
|
||||
<li>
|
||||
|
|
@ -158,6 +161,8 @@
|
|||
<li>
|
||||
<strong><a class="man-ref" href="git-fresh-branch.html">git-fresh-branch<span class="s">(1)</span></a></strong> Create fresh branches</li>
|
||||
<li>
|
||||
<strong><a class="man-ref" href="git-get.html">git-get<span class="s">(1)</span></a></strong> Clone a Git repository under a configured directory</li>
|
||||
<li>
|
||||
<strong><a class="man-ref" href="git-gh-pages.html">git-gh-pages<span class="s">(1)</span></a></strong> Create the GitHub Pages branch</li>
|
||||
<li>
|
||||
<strong><a class="man-ref" href="git-graft.html">git-graft<span class="s">(1)</span></a></strong> Merge and destroy a given branch</li>
|
||||
|
|
@ -260,7 +265,7 @@
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>December 2021</li>
|
||||
<li class='tc'>May 2023</li>
|
||||
<li class='tr'>git-extras(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ git-extras(1) -- Awesome GIT utilities
|
|||
- **git-force-clone(1)** overwrite local repositories with clone
|
||||
- **git-fork(1)** Fork a repo on github
|
||||
- **git-fresh-branch(1)** Create fresh branches
|
||||
- **git-get(1)** Clone a Git repository under a configured directory
|
||||
- **git-gh-pages(1)** Create the GitHub Pages branch
|
||||
- **git-graft(1)** Merge and destroy a given branch
|
||||
- **git-guilt(1)** calculate change between two revisions
|
||||
|
|
|
|||
28
man/git-get.1
Normal file
28
man/git-get.1
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
.\" generated with Ronn-NG/v0.9.1
|
||||
.\" http://github.com/apjanke/ronn-ng/tree/0.9.1
|
||||
.TH "GIT\-GET" "1" "May 2023" "" "Git Extras"
|
||||
.SH "NAME"
|
||||
\fBgit\-get\fR \- Clone a Git repository under a directory
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-get\fR
|
||||
.SH "DESCRIPTION"
|
||||
Clones a Git repository under the directory specified by the Git configuration \fBgit\-extras\.get\.clone\-path\fR
|
||||
.SH "EXAMPLES"
|
||||
.nf
|
||||
$ git config \-\-add git\-extras\.get\.clone\-path "$HOME/some\-dir"
|
||||
$ git get 'https://github\.com/hyperupcall/bake'
|
||||
Cloning into '/home/<user>/some\-dir/bake'\|\.\|\.\|\.
|
||||
remote: Enumerating objects: 1199, done\.
|
||||
remote: Counting objects: 100% (378/378), done\.
|
||||
remote: Compressing objects: 100% (174/174), done\.
|
||||
remote: Total 1199 (delta 163), reused 357 (delta 146), pack\-reused 821
|
||||
Receiving objects: 100% (1199/1199), 3\.05 MiB | 9\.85 MiB/s, done\.
|
||||
Resolving deltas: 100% (515/515), done\.
|
||||
$
|
||||
.fi
|
||||
.SH "AUTHOR"
|
||||
Written by Edwin Kofler <\fIedwin@kofler\.dev\fR>
|
||||
.SH "REPORTING BUGS"
|
||||
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
|
||||
.SH "SEE ALSO"
|
||||
<\fIhttps://github\.com/tj/git\-extras\fR>
|
||||
119
man/git-get.html
Normal file
119
man/git-get.html
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='content-type' content='text/html;charset=utf8'>
|
||||
<meta name='generator' content='Ronn-NG/v0.9.1 (http://github.com/apjanke/ronn-ng/tree/0.9.1)'>
|
||||
<title>git-get(1) - Clone a Git repository under a directory</title>
|
||||
<style type='text/css' media='all'>
|
||||
/* style: man */
|
||||
body#manpage {margin:0}
|
||||
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
|
||||
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
|
||||
.mp h2 {margin:10px 0 0 0}
|
||||
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
|
||||
.mp h3 {margin:0 0 0 4ex}
|
||||
.mp dt {margin:0;clear:left}
|
||||
.mp dt.flush {float:left;width:8ex}
|
||||
.mp dd {margin:0 0 0 9ex}
|
||||
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
|
||||
.mp pre {margin-bottom:20px}
|
||||
.mp pre+h2,.mp pre+h3 {margin-top:22px}
|
||||
.mp h2+pre,.mp h3+pre {margin-top:5px}
|
||||
.mp img {display:block;margin:auto}
|
||||
.mp h1.man-title {display:none}
|
||||
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
|
||||
.mp h2 {font-size:16px;line-height:1.25}
|
||||
.mp h1 {font-size:20px;line-height:2}
|
||||
.mp {text-align:justify;background:#fff}
|
||||
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
|
||||
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
|
||||
.mp u {text-decoration:underline}
|
||||
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
|
||||
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
|
||||
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
|
||||
.mp b.man-ref {font-weight:normal;color:#434241}
|
||||
.mp pre {padding:0 4ex}
|
||||
.mp pre code {font-weight:normal;color:#434241}
|
||||
.mp h2+pre,h3+pre {padding-left:0}
|
||||
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
|
||||
ol.man-decor {width:100%}
|
||||
ol.man-decor li.tl {text-align:left}
|
||||
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
|
||||
ol.man-decor li.tr {text-align:right;float:right}
|
||||
</style>
|
||||
</head>
|
||||
<!--
|
||||
The following styles are deprecated and will be removed at some point:
|
||||
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
|
||||
|
||||
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
|
||||
.man-navigation should be used instead.
|
||||
-->
|
||||
<body id='manpage'>
|
||||
<div class='mp' id='man'>
|
||||
|
||||
<div class='man-navigation' style='display:none'>
|
||||
<a href="#NAME">NAME</a>
|
||||
<a href="#SYNOPSIS">SYNOPSIS</a>
|
||||
<a href="#DESCRIPTION">DESCRIPTION</a>
|
||||
<a href="#EXAMPLES">EXAMPLES</a>
|
||||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
<a href="#SEE-ALSO">SEE ALSO</a>
|
||||
</div>
|
||||
|
||||
<ol class='man-decor man-head man head'>
|
||||
<li class='tl'>git-get(1)</li>
|
||||
<li class='tc'>Git Extras</li>
|
||||
<li class='tr'>git-get(1)</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
<h2 id="NAME">NAME</h2>
|
||||
<p class="man-name">
|
||||
<code>git-get</code> - <span class="man-whatis">Clone a Git repository under a directory</span>
|
||||
</p>
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-get</code></p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
<p>Clones a Git repository under the directory specified by the Git configuration <code>git-extras.get.clone-path</code></p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<pre><code>$ git config --add git-extras.get.clone-path "$HOME/some-dir"
|
||||
$ git get 'https://github.com/hyperupcall/bake'
|
||||
Cloning into '/home/<user>/some-dir/bake'...
|
||||
remote: Enumerating objects: 1199, done.
|
||||
remote: Counting objects: 100% (378/378), done.
|
||||
remote: Compressing objects: 100% (174/174), done.
|
||||
remote: Total 1199 (delta 163), reused 357 (delta 146), pack-reused 821
|
||||
Receiving objects: 100% (1199/1199), 3.05 MiB | 9.85 MiB/s, done.
|
||||
Resolving deltas: 100% (515/515), done.
|
||||
$
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Edwin Kofler <<a href="mailto:edwin@kofler.dev" data-bare-link="true">edwin@kofler.dev</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
<p><<a href="https://github.com/tj/git-extras/issues" data-bare-link="true">https://github.com/tj/git-extras/issues</a>></p>
|
||||
|
||||
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||||
|
||||
<p><<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>></p>
|
||||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>May 2023</li>
|
||||
<li class='tr'>git-get(1)</li>
|
||||
</ol>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
35
man/git-get.md
Normal file
35
man/git-get.md
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
git-get(1) -- Clone a Git repository under a configured directory
|
||||
=================================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-get`
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Clones a Git repository under the directory specified by the Git configuration `git-extras.get.clone-path`
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
$ git config --add git-extras.get.clone-path "$HOME/some-dir"
|
||||
$ git get 'https://github.com/hyperupcall/bake'
|
||||
Cloning into '/home/<user>/some-dir/bake'...
|
||||
remote: Enumerating objects: 1199, done.
|
||||
remote: Counting objects: 100% (378/378), done.
|
||||
remote: Compressing objects: 100% (174/174), done.
|
||||
remote: Total 1199 (delta 163), reused 357 (delta 146), pack-reused 821
|
||||
Receiving objects: 100% (1199/1199), 3.05 MiB | 9.85 MiB/s, done.
|
||||
Resolving deltas: 100% (515/515), done.
|
||||
$
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Written by Edwin Kofler <<edwin@kofler.dev>>
|
||||
|
||||
## REPORTING BUGS
|
||||
|
||||
<<https://github.com/tj/git-extras/issues>>
|
||||
|
||||
## SEE ALSO
|
||||
|
||||
<<https://github.com/tj/git-extras>>
|
||||
|
|
@ -28,6 +28,7 @@ git-feature(1) git-feature
|
|||
git-force-clone(1) git-force-clone
|
||||
git-fork(1) git-fork
|
||||
git-fresh-branch(1) git-fresh-branch
|
||||
git-get(1) git-get
|
||||
git-gh-pages(1) git-gh-pages
|
||||
git-graft(1) git-graft
|
||||
git-guilt(1) git-guilt
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ git-bulk
|
|||
git-extras
|
||||
git-force-clone
|
||||
git-fork
|
||||
git-get
|
||||
git-ignore
|
||||
git-setup
|
||||
git-standup
|
||||
|
|
|
|||
Loading…
Reference in a new issue