创建项目,并与远程连接提交,需要存在远程项目
echo "# 4119-44441-Sorting" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/MyName/test5.git
git push -u origin master
创建远程项目:
curl -u "Username:token" https://api.github.com/user/repos -d '{"name":"'test5'"}'
连接远程仓库提交:
git remote add origin https://github.com/MyName/test.git
git push -u origin master
无需输入密码连接远程仓库提交:
git remote add origin git@github.com:MyName/test5.git
git push -u origin master
完整演示:
import os
os.chdir("test7")
os.system("git init")
os.system("git add .")
cmd ="curl -u \"MyName:xxxxxxxxxx\" https://api.github.com/user/repos -d \'{\"name\":\"" + repoName +"\"}\'"
os.system(cmd)
os.system("git commit -m test")
os.system("git remote add origin git@github.com:MyName/test7.git")
os.system("git push -u origin master")