系统相关
首页 > 系统相关> > linux – 使用终端的别名创建一个git repo

linux – 使用终端的别名创建一个git repo

作者:互联网

嘿,我想创建一个像这样的git存储库:

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'

但是我想在终端(Ubuntu)中使用别名来做,比如

alias newRepo = curl -u 'USER' https://api.github.com/user/repos -d '{"name":"$1"}';
                git remote add origin git@github.com:USER/$1.git;

所以在终端后我输入:

newRepo test

它创建了回购并添加了远程“原点”.

解决方法:

你可以这样做:

首先创建一个脚本newRepo:

#!/bin/bash
user="$1"
reponame="$2"
if [ "$user" = "" ]; then
read -p "Enter Github username: " user
fi
if [ "$reponame" = "" ]; then
read -p "Enter Github Repository Name: " reponame
fi
curl -u "$user" https://api.github.com/user/repos -d "{\"name\":\"$reponame\"}"

然后制作别名:

alias newRepo=/pathtothenewReposcript

现在你可以使用:

newRepo username reponame

在github中创建一个新的存储库.

标签:bash,linux,git,terminal,ubuntu-14-04
来源: https://codeday.me/bug/20190829/1764137.html