如何创建在Github上使用Git的bash一个新的回购?
如何创建从使用Git的bash我的机器上一个新的资料库?如何创建在Github上使用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
但我发现了“致命的错误:你在服务器上运行更新服务器的信息?”
只是试图在最后一行添加-u:
git push -u origin master
这不适用于创建新的回购。 -u是--set-upstream的缩写。这里解释得非常好:http://stackoverflow.com/questions/6089294/why-do-i-need-to-do-set-upstream-all-the-time – alexbhandari 2013-12-23 05:30:26
可能创造在github回购的最简单的方法是什么地方之前该行:
git remote add origin https://github.com/username/Hello-World.git
去https://github.com/new并在github上创建一个仓库,然后运行你的最后两行,一切都应该工作。
是否没有办法创建一个新的回购(在github.com上)从终端? – skube 2014-07-02 15:11:30
也许你收到此错误,因为你没有设置你的身份:
$ git config --global user.name "John Doe" $ git config --global user.email [email protected]
在这里您可以找到步骤创建并把你的仓库在github: http://programertools.blogspot.com/2014/04/how-to-use-github.html
首先,尝试混帐推前这样做的权利:
git pull repo branch
然后尽量做到以下几点:
$ git init --bare yourreponame.git
然后你在做什么之前:
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
我用Postman创建了一个存储库,然后使用命令'git remote add origin
我认为这是可行的。
你可以把它使用curl(如果你使用的是Windows,你必须安装它)
curl -u USER https://api.github.com/user/repos -d '{ "name": "REPO" }'
确保你的GitHub用户名替换用户和回购和库的名字你想要分别创建
它要求输入密码,输入你的github管理员密码,你很好走。
我创造了这个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 [email protected]:USERNAME/$reponame.git
git push -u origin master
那么如何:
复制上面的代码。将其保存为NAME.sh,将其添加到PATH中。重新启动终端或打开一个新的终端。
$ NAME newreponame
$ NAME
$ Enter Github Repository Name:
谢谢。
Duplicate http://stackoverflow.com/a/27456812/874188表明存在(现在?)一个API。 – tripleee 2014-12-13 08:26:52