本地安装git,然后切入到要上传代码的文件夹内
###1.文件夹git初始化
git init
###2.设置远程仓库地址
git remote add origin [远程仓库地址]
如:git remote add origin wwww.baidu.com/demo
###3.添加文件到git本地仓库
git add .
注意:add . 即为添加所有文件,也可以git add [文件名]添加单个文件
###4.本地仓库提交代码并添加备注
git commit -m "推送备注"
如:git commit -m "first commit"
###5.推送git本地代码到远程仓库
git push origin [分支]
如: git push origin master, 推送到master分支
注意:推送到某个分支必须分支存在,否则报错
如果报错 Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing 可以使用 git pull origin master --allow-unrelated-histories 然后再git push origin master