git-clonepath is a Git external subcommand that derives every clone
destination from the remote:
<clonepath.root>/<host>/<repository-path>
For example:
git config --global clonepath.root ~/Developer
git clonepath git@github.com:nkaewam/git-clonepath.gitclones into:
~/Developer/github.com/nkaewam/git-clonepath
Git must already be installed. Prebuilt git-clonepath binaries are available
for macOS and Linux on AMD64 and ARM64.
Install the appropriate prebuilt release binary from the
nkaewam/tap tap:
brew install nkaewam/tap/git-clonepathGo is not required. To upgrade later:
brew update
brew upgrade git-clonepathVerify that the executable is available:
command -v git-clonepathWithout Homebrew, download and verify the archive for the current operating
system and CPU architecture from
GitHub Releases. Set
VERSION to the release tag to install:
VERSION=v0.1.1
case "$(uname -s)" in
Darwin) OS=darwin ;;
Linux) OS=linux ;;
*) echo "Unsupported operating system: $(uname -s)" >&2; exit 1 ;;
esac
case "$(uname -m)" in
x86_64|amd64) ARCH=amd64 ;;
arm64|aarch64) ARCH=arm64 ;;
*) echo "Unsupported CPU architecture: $(uname -m)" >&2; exit 1 ;;
esac
PACKAGE="git-clonepath_${VERSION#v}_${OS}_${ARCH}"
ARCHIVE="${PACKAGE}.tar.gz"
BASE_URL="https://github.com/nkaewam/git-clonepath/releases/download/${VERSION}"
curl -fLO "${BASE_URL}/${ARCHIVE}"
curl -fLO "${BASE_URL}/SHA256SUMS"
if [ "${OS}" = darwin ]; then
grep " ${ARCHIVE}$" SHA256SUMS | shasum -a 256 -c -
else
grep " ${ARCHIVE}$" SHA256SUMS | sha256sum -c -
fi
tar -xzf "${ARCHIVE}"
mkdir -p "${HOME}/.local/bin"
install -m 0755 "${PACKAGE}/git-clonepath" "${HOME}/.local/bin/git-clonepath"Ensure ~/.local/bin is on PATH, adding the export to your shell profile if
needed:
export PATH="${HOME}/.local/bin:${PATH}"
command -v git-clonepathWith Go installed, build and install the latest tagged version:
go install github.com/nkaewam/clone-path/cmd/git-clonepath@latestEnsure the Go binary directory is on PATH, then verify the installation:
command -v git-clonepathGit automatically exposes an executable named git-clonepath as
git clonepath.
The clone root is required. It must resolve to an absolute, existing directory:
mkdir -p ~/Developer
git config --global clonepath.root ~/DeveloperNormal Git configuration precedence applies, including one-off overrides:
git -c clonepath.root=~/Work clonepath https://github.com/acme/widgets.gitSCP-style SSH, ssh://, and https:// remotes are supported:
git clonepath git@github.com:acme/widgets.git
git clonepath ssh://git@github.com:2222/acme/widgets.git
git clonepath https://github.com/acme/widgets.gitClone options before the remote are forwarded unchanged:
git clonepath --depth 1 --branch main https://github.com/acme/widgets.gitAfter a successful clone, the command logs a shell-safe command that can be copied to enter the new repository:
git-clonepath: next command:
cd /Users/alice/Developer/github.com/acme/widgets
The original remote is passed to Git unchanged. Usernames and ports are omitted
only when deriving the local path. Local and file:// remotes are rejected, as
are unsafe or malformed repository paths.
An existing destination is always an error. On a failed clone, the command removes only the empty host and namespace directories it created. Git's standard input, output, error, credential handling, and exact clone exit status are preserved.
task test
task integrationBuild the supported release targets:
task releaseRelease Please monitors commits pushed to main and maintains a release pull
request. Use Conventional Commits:
fix: makes a patch release, feat: makes a minor release, and ! denotes a
breaking change and makes a major release. Merging the release pull request
creates the version tag automatically.
The release workflow tests the project, builds all four targets, generates
SHA256SUMS, creates a GitHub Release with generated release notes, and updates
the formula in nkaewam/homebrew-tap.
For the Homebrew update, add a HOMEBREW_TAP_TOKEN Actions repository secret.
Use a fine-grained personal access token with read/write access to repository
contents for only nkaewam/homebrew-tap.
To retry only the Homebrew update for an existing release, run the Release
workflow manually, enter its tag, and select Update the Homebrew formula
without rebuilding or republishing the release.