1. 在github上创建一个目录xxxx.git
2. 切换到本地目录
git init git remote add origin xxxx.git //xxx.git就是你在远程github上创建资源http地址 git add --all git commit -m ‘add‘ git push origin master
此时有可能会push不成功,报如下错误:
Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., ‘git pull ...‘) before pushing again.
这是因为在github上创建目录时添加了内容比如README.txt,因此本地仓库并不是最新,需要先更新本地目录保持与远端一致:
git pull origin master
再次执行push命令
git push origin master
时间: 2024-11-04 04:36:16