Jaf*_*ick 20 github github-api git-bash
如何使用git bash从我的机器创建新的存储库?
我按照以下步骤操作:
mkdir ~/Hello-World
cd ~/Hello-World
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin https://github.com/username/Hello-World.git
git push origin master
Run Code Online (Sandbox Code Playgroud)
但是我得到了"致命的错误:你在服务器上运行了update-server-info吗?"
我创建了这个bash文件来自动完成所有操作.
#!/bin/sh
reponame="$1"
if [ "$reponame" = "" ]; then
read -p "Enter Github Repository Name: " reponame
fi
mkdir ./$reponame
cd $reponame
curl -u USERNAME https://api.github.com/user/repos -d "{\"name\":\"$reponame\"}"
git init
echo "ADD README CONTENT" > README.md
git add README.md
git commit -m "Starting Out"
git remote add origin git@github.com:USERNAME/$reponame.git
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
又怎样:
复制上面的代码.将其保存为NAME.sh,将其添加到PATH中.重启终端或打开一个新终端.
$ NAME newreponame
$ NAME
$ Enter Github Repository Name:
Run Code Online (Sandbox Code Playgroud)
谢谢.
可能在github上创建repo的最简单方法是在这行之前的某个地方:
git remote add origin https://github.com/username/Hello-World.git
Run Code Online (Sandbox Code Playgroud)
转到https://github.com/new并在github上创建一个存储库,然后运行你的最后两行,一切都应该工作.
| 归档时间: |
|
| 查看次数: |
51263 次 |
| 最近记录: |