git 问题解决总结
记录git 问题1.git push 报错non-fast-forward$ git push origin masterTo ../remote/! [rejected]master -> master (non-fast forward)error: failed to push some refs to '../remote/'o p...
- 记录git 问题
1.git push 报错non-fast-forward
$ git push origin master
To ../remote/
! [rejected] master -> master (non-fast forward)
error: failed to push some refs to '../remote/'
o prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'non-fast forward'
section of 'git push --help' for details.
This error can be a bit overwhelming at first, do not fear. Simply put, git cannot make the change on the remote without losing commits, so it refuses the push. Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.
In other cases this error is a result of destructive changes made locally by using commands like git commit --amend or git rebase. While you can override the remote by adding --force to the push command, you should only do so if you are absolutely certain this is what you want to do. Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.
解决方法:
//强推,即利用强覆盖方式用你本地的代码替代git仓库内的内容
git push -f origin master
2.上传本地代码到公司gitlab 报错:
执行git remote add origin ssh://xxx/xxx/xxx.git
fatal: remote origin already exists.(报错远程起源已经存在。)
问题:上传的代码已经有远程源。
:~/Documents/openblt$ git remote -v
origin https://github.com/feaser/openblt.git (fetch)
解决方法:
1、git remote rm origin
2、git remote add origin ssh://xxx/xxx/xxx.git
3、git push origin master
开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!
更多推荐
所有评论(0)