1、运行git push -u origin master
时报错如下:
! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘git@github.com:******/configserver.git’
hint: 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.
hint: See the ‘Note about fast-forwards’ in ‘git push --help’ for details.
修改方案:
先 运行git pull --rebase origin master
,【注:pull=fetch+merge]
将远程仓库代码拉到本地合并后;
再运行git push -u origin master
即可完成代码上传到github
2、将本地仓库上传到远程仓库步骤
1)git init #创建本地仓库
2)git add . #添加所有文件
git add somefile #添加某一个文件
3)git commit -m ‘第一次提交’ #将文件添加到仓库
4)git remote add origin git@github.com?*****/configserver.git #连接仓库
5)git push origin master #将本地代码提交到远程仓库
如果报上面的错误的话,先执行git pull --rebase origin master
,
再执行 git push origin master
其他:git status #查看状态
Git Error: failed to push some refs to Updates were rejected because the remote contains work tha
最新推荐文章于 2024-04-14 08:15:00 发布