diff --git a/Commands.md b/Commands.md index 4cca302ee..75204ba56 100644 --- a/Commands.md +++ b/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 `name`: $ git fresh-branch docs ``` +## git get + +Clone repository into `"$GIT_EXTRA_DEFAULT_CLONE_PATH/"`: + +```bash +$ export GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" +$ git-get 'https://github.com/hyperupcall/bake' +``` + ## git guilt Calculate the change in blame between two revisions diff --git a/bin/git-get b/bin/git-get new file mode 100755 index 000000000..8f0ea3ffb --- /dev/null +++ b/bin/git-get @@ -0,0 +1,35 @@ +#!/usr/bin/env bash + +_usage() { + printf '%s\n' "usage: ${0##*/} +usage: ${0##*/} --help + +Clone a repository in a particular directory." +} + +url=$1 + +if (( $# == 0)); then + _usage + exit 0 +fi + +for arg; do + if [ "$arg" = '-h' ] || [ "$arg" = '--help' ]; then + _usage + exit 0 + fi +done + + +if [ -z "$GIT_EXTRA_DEFAULT_CLONE_PATH" ]; then + printf 'ERROR: %s\n' "Environment variable 'GIT_EXTRA_DEFAULT_CLONE_PATH' must be set to a directory to clone under" >&2 + exit 1 +fi + +dirname=${url%/} +dirname=${url%.git} +dirname=${dirname##*/} + +mkdir -p "$GIT_EXTRA_DEFAULT_CLONE_PATH" +git clone "$url" "$GIT_EXTRA_DEFAULT_CLONE_PATH/$dirname" diff --git a/man/git-extras.md b/man/git-extras.md index aa77cfe27..196491757 100644 --- a/man/git-extras.md +++ b/man/git-extras.md @@ -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 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 diff --git a/man/git-get.1 b/man/git-get.1 new file mode 100644 index 000000000..b9b3f629d --- /dev/null +++ b/man/git-get.1 @@ -0,0 +1,27 @@ +.\" 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 environment variable \fBGIT_EXTRA_DEFAULT_CLONE_PATH\fR +.SH "EXAMPLES" +.nf +$ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some\-dir" git\-get 'https://github\.com/hyperupcall/bake' +Cloning into '/home//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> diff --git a/man/git-get.html b/man/git-get.html new file mode 100644 index 000000000..f2faed8f4 --- /dev/null +++ b/man/git-get.html @@ -0,0 +1,118 @@ + + + + + + git-get(1) - Clone a Git repository under a directory + + + + +
+ + + +
    +
  1. git-get(1)
  2. +
  3. Git Extras
  4. +
  5. git-get(1)
  6. +
+ + + +

NAME

+

+ git-get - Clone a Git repository under a directory +

+

SYNOPSIS

+ +

git-get

+ +

DESCRIPTION

+ +

Clones a Git repository under the directory specified by the environment variable GIT_EXTRA_DEFAULT_CLONE_PATH

+ +

EXAMPLES

+ +
$ GIT_EXTRA_DEFAULT_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>

+ +
    +
  1. +
  2. May 2023
  3. +
  4. git-get(1)
  5. +
+ +
+ + diff --git a/man/git-get.md b/man/git-get.md new file mode 100644 index 000000000..eff82097f --- /dev/null +++ b/man/git-get.md @@ -0,0 +1,34 @@ +git-get(1) -- Clone a Git repository under a directory +================================================= + +## SYNOPSIS + +`git-get` + +## DESCRIPTION + + Clones a Git repository under the directory specified by the environment variable `GIT_EXTRA_DEFAULT_CLONE_PATH` + +## EXAMPLES + + $ GIT_EXTRA_DEFAULT_CLONE_PATH="$HOME/some-dir" git-get 'https://github.com/hyperupcall/bake' + Cloning into '/home//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 <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> diff --git a/man/index.txt b/man/index.txt index 0e0381696..f54005e5b 100644 --- a/man/index.txt +++ b/man/index.txt @@ -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