sh 克隆到新的仓库并快速切换到它。有助于避免在我的主目录中随意收集无组织的github repos。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 克隆到新的仓库并快速切换到它。有助于避免在我的主目录中随意收集无组织的github repos。相关的知识,希望对你有一定的参考价值。

#!/bin/sh -e

# A simple script to keep a tidy ~/src directory organized by owner & then repo
# When the script is done, just hit command-v to switch into the directory
# (Github and Mac only. Sorry, openness!)
#
# Usage:
#   gloan <org>/<repo>
# Or:
#   gloan <org> <repo>
#
# example: gloan testdouble/testdouble.js
#
# Once cloned, will copy a "cd" command to quickly change into repo directory

IFS="/" read -ra ADDR <<< "$1"

SRC_DIR="$HOME/src"

ORG="${ADDR[0]}"
REPO="${ADDR[1]-$2}"

ORG_DIR="$SRC_DIR/$ORG"
REPO_DIR="$ORG_DIR/$REPO"

# Make sure org directory exists
mkdir -p "$ORG_DIR"

# Make sure it's not already cloned, then clone
if [ -d "$REPO_DIR" ]; then
  echo "It looks like the repo was already cloned."
else
  git clone "git@github.com:$ORG/$REPO.git" "$REPO_DIR"
fi

printf "cd %s/%s/%s" "$SRC_DIR" "$ORG" "$REPO" | pbcopy
echo "Hit Command-V to cd into the repo!"

以上是关于sh 克隆到新的仓库并快速切换到它。有助于避免在我的主目录中随意收集无组织的github repos。的主要内容,如果未能解决你的问题,请参考以下文章

迁移一个仓库到新的Gitlab

Git仓库完整迁移

Git 获取项目git clone

Git-仓库迁移

一文掌握 Kafka 集群快速扩容的方案

避坑指南:Kafka集群快速扩容的方案总结