如何推送或拉取到多个 git 远程服务器
How do I push or pull to multiple git remote server
我在 Github 中有一个现有的存储库,然后我决定将此存储库也托管在 bitbucket 和 gitlab 中。
然后我将 GitLab 和 bitbucket 的远程存储库添加到 git 配置并成功推送到多个服务器。
在本地 machine/pc 和 GitHub 上更改时推送有效,在 GitHub 在线服务器上更改时推送也有效,并再次提交并推送到所有远程服务器。
问题是当我从 bitbucket 或 GitLab 更改任何代码然后尝试拉取到本地 machine/pc 它没有拉取。因此,我在本地 machine/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 'git@bitbucket.org: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 'git@gitlab.com: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 服务器拉取不工作,我将如何在从本地存储库更改内容后再次推送它们。
有什么解决办法吗?
您可以为您的项目设置两个不同的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>
我在 Github 中有一个现有的存储库,然后我决定将此存储库也托管在 bitbucket 和 gitlab 中。
然后我将 GitLab 和 bitbucket 的远程存储库添加到 git 配置并成功推送到多个服务器。 在本地 machine/pc 和 GitHub 上更改时推送有效,在 GitHub 在线服务器上更改时推送也有效,并再次提交并推送到所有远程服务器。
问题是当我从 bitbucket 或 GitLab 更改任何代码然后尝试拉取到本地 machine/pc 它没有拉取。因此,我在本地 machine/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 'git@bitbucket.org: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 'git@gitlab.com: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 服务器拉取不工作,我将如何在从本地存储库更改内容后再次推送它们。
有什么解决办法吗?
您可以为您的项目设置两个不同的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>