一、設(shè)置git倉庫
1、先刪除原來倉庫
git remote rm origin
2、添加倉庫
git remote add origin [url]
注意:若要修改倉庫
git remote origin set-url [url]
二、
在使用Git 配置公司的遠(yuǎn)程倉庫時git push origin master
,出現(xiàn)以下問題
xu:QProj xiaokai$ git push origin master
To https://gitee.com/XXXXX.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/XXXXX.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
從提示語中可以看出是,問題(Non-fast-forward)的出現(xiàn)原因在于:git倉庫中已經(jīng)有一部分代碼,所以它不允許你直接把你的代碼覆蓋上去。于是你有2個選擇方式:
(一)、強制推送,即利用強覆蓋方式用你本地的代碼替代git倉庫內(nèi)的內(nèi)容,如果遠(yuǎn)程倉庫是剛建的,沒有代碼,可以這樣操作,盡量避免這種操作方法。
git push -f
(二)、
先把git的東西fetch到你本地然后merge后再push
git fetch
git merge
注意:
1、在使用的時候,git merge
,又出現(xiàn)了以下的問題
xu:QProj xiaokai$ git merge
fatal: refusing to merge unrelated histories
對于這個問題。使用
git pull origin master --allow-unrelated-histories
然后繼續(xù)
git merge
,依然有問題
fatal: You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you merge.
這個就好處理了,是我們沒有提交當(dāng)前的變化,
git add .
git commit -m "modify"
然后再來一次
git merge
然后輸入
git pull
顯示 Already up-to-date.
最后執(zhí)行
git push origin master
顯示文章來源:http://www.zghlxwxcb.cn/news/detail-795932.html
xu:QProj xiaokai$ git push origin master
Counting objects: 693, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (636/636), done.
Writing objects: 100% (693/693), 2.83 MiB | 570.00 KiB/s, done.
Total 693 (delta 362), reused 0 (delta 0)
remote: Resolving deltas: 100% (362/362), completed with 1 local object.
remote: Powered by Gitee.com
To https://gitee.com/XXXXX.git
?? 83902a5..8100890? master -> master文章來源地址http://www.zghlxwxcb.cn/news/detail-795932.html
到了這里,關(guān)于git 上傳出現(xiàn)“ ! [rejected] master -> master (non-fast-forward)”的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!