本地与远程github仓库的关联以及代码的提交问题

step1:将本地的project关联都远程github仓库

git remote add origin2 远程仓库地址

注:此处的初始命令本来是git remote add origin 远程仓库地址,但是由于自己所建的远程仓库是origin,所以在此处要写成origin2,否则就会报错 。

fatal:remote origin already exists.

step2:将本地的初始代码上传至远程仓库

git push -u origin2 master

注:因为是首次上传,所以加了-u。

step3:将修改并完成的代码上传,和直接fork到自己仓库的代码上传稍有不同,如下:

(1) git add .
(2)git commit -m "" (注:此处必须是双引号,否则会报错)
(3)也可使用git remote -v 查看已经存在的远程仓库;(可选)
(4)git push origin2 master

这样,就完成了本地project与远程github仓库的连接和代码的提交。

你可能感兴趣的:(本地与远程github仓库的关联以及代码的提交问题)