我在 Github 中有一個現有的存盤庫,然后我決定同時托管這個存盤庫 bitbucket 和 gitlab。
然后我將 GitLab 和 bitbucket 的遠程存盤庫添加到 git config 并成功推送到多個服務器。在本地機器/pc 上更改時推送正在作業,而 GitHub 在 GitHub 在線服務器上更改時也可以正常作業,并拉取提交并再次推送到所有遠程服務器。
問題是當我從 bitbucket 或 GitLab 更改任何代碼,然后嘗試拉到本地機器/PC 時它沒有拉。所以,我在我的本地機器/電腦上改變了一些東西,然后在提交之后嘗試推送,但推送只在 GitHub 和 Gitlab Bitbucket 推送不起作用(不更新遠程存盤庫)。
asifulmamun@asifulmamun:~/script/Youtube-Projects$ git push
Everything up-to-date
To bitbucket.org:asifulmamun/youtube-projects.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:asifulmamun/youtube-projects.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.
To gitlab.com:asifulmamun/youtube-projects.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:asifulmamun/youtube-projects.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.
Gitlab 和 Bitbucket 遠程服務器告訴我拉存盤庫然后嘗試推送。但是,拉動不起作用。向我展示所有最新資訊,因為此拉取僅適用于 GitHub,不適用于 Bitbucket 和 Gitlab。
asifulmamun@asifulmamun:~/script/Youtube-Projects$ git pull
Already up to date.
但是,如果從 Bitbucket 或 Gitlab 服務器上拉取不起作用,我將如何在從本地存盤庫更改某些內容后再次推送它們。
有什么解決辦法嗎?
uj5u.com熱心網友回復:
您可以為您的專案設定兩個不同的remotes(跟蹤的存盤庫):
git remote add bitbucket <the_path_for_bitbucket_project>
git remote add gitlab <the_path_for_gitlab_project>
然后,每當您想從中提取時bitbucket,您都可以運行:
git pull bitbucket <branch_name>
然后,如果您想將某些東西推送到gitlab例如,您可以運行:
git push gitlab <branch_name>
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/459131.html
