# Repository mirroring
> 原文:[https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html](https://docs.gitlab.com/ee/user/project/repository/repository_mirroring.html)
* [Overview](#overview)
* [Use cases](#use-cases)
* [Pushing to a remote repository](#pushing-to-a-remote-repository-core)
* [Configuring push mirrors through the API](#configuring-push-mirrors-through-the-api)
* [Push only protected branches](#push-only-protected-branches-core)
* [Keep divergent refs](#keep-divergent-refs-core)
* [Setting up a push mirror from GitLab to GitHub](#setting-up-a-push-mirror-from-gitlab-to-github-core)
* [Setting up a push mirror to another GitLab instance with 2FA activated](#setting-up-a-push-mirror-to-another-gitlab-instance-with-2fa-activated)
* [Pulling from a remote repository](#pulling-from-a-remote-repository-starter)
* [How it works](#how-it-works)
* [SSH authentication](#ssh-authentication)
* [SSH public key authentication](#ssh-public-key-authentication)
* [Overwrite diverged branches](#overwrite-diverged-branches-starter)
* [Only mirror protected branches](#only-mirror-protected-branches-starter)
* [Hard failure](#hard-failure-starter)
* [Trigger update using API](#trigger-update-using-api-starter)
* [Forcing an update](#forcing-an-update-core)
* [Bidirectional mirroring](#bidirectional-mirroring-starter)
* [Configure a webhook to trigger an immediate pull to GitLab](#configure-a-webhook-to-trigger-an-immediate-pull-to-gitlab)
* [Preventing conflicts using a `pre-receive` hook](#preventing-conflicts-using-a-pre-receive-hook)
* [Mirroring with Perforce Helix via Git Fusion](#mirroring-with-perforce-helix-via-git-fusion-starter)
* [Troubleshooting](#troubleshooting)
* [13:Received RST_STREAM with error code 2 with GitHub](#13received-rst_stream-with-error-code-2-with-github)
# Repository mirroring[](#repository-mirroring "Permalink")
存儲庫鏡像允許將存儲庫鏡像到外部源或從外部源鏡像. 它可用于鏡像存儲庫之間的分支,標簽和提交.
GitLab 上的存儲庫鏡像將自動更新. 您也可以最多每 5 分鐘手動觸發一次更新.
## Overview[](#overview "Permalink")
當您想在 GitLab 之外使用存儲庫時,存儲庫鏡像很有用.
GitLab 支持兩種存儲庫鏡像:
* 推送:用于將 GitLab 存儲庫鏡像到另一個位置.
* Pull: for mirroring a repository from another location to GitLab.
鏡像存儲庫更新后,所有新的分支,標記和提交將在項目的活動提要中可見.
至少具有[開發人員訪問](../../permissions.html)項目[權限](../../permissions.html)的用戶也可以強制立即更新,除非:
* 鏡像已被更新.
* 自上次更新以來,還沒有過去 5 分鐘.
出于安全原因,在[GitLab 12.10 和更高版本中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27166) ,原始存儲庫的 URL 僅顯示給對鏡像項目具有維護者或所有者權限的用戶.
## Use cases[](#use-cases "Permalink")
以下是存儲庫鏡像的一些可能的用例:
* 您遷移到了 GitLab,但仍需要將項目保留在另一個源中. 在這種情況下,您只需將其設置為鏡像到 GitLab(拉),所有提交,標簽和分支的基本歷史記錄都將在您的 GitLab 實例中提供.
* 您在另一個源中有舊項目,這些舊項目不再使用,但又不想出于歸檔目的而刪除它們. 在這種情況下,您可以創建一個推送鏡像,以便您的活動 GitLab 存儲庫可以將其更改推送到舊位置.
## Pushing to a remote repository[](#pushing-to-a-remote-repository-core "Permalink")
版本歷史
* 在 GitLab 企業版 8.7 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/249) .
* 在 10.8 版中[移至 GitLab Core](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18715) .
對于現有項目,可以按如下所示設置推送鏡像:
1. 導航到項目的**"設置">"存儲庫",**然后展開" **鏡像存儲庫"**部分.
2. 輸入存儲庫 URL.
3. 從**鏡像方向**下拉菜單中選擇**推送** .
4. 如有必要,請從" **身份驗證方法"**下拉列表中選擇一種身份**驗證方法** .
5. 如有必要,請選中**僅鏡像保護的分支**框.
6. 如果需要, **請**選中" **保持差異引用"**框.
7. 單擊**鏡像存儲庫**按鈕以保存配置.
[](img/repository_mirroring_push_settings.png)
啟用推送鏡像后,只有推送會直接提交到鏡像存儲庫,以防止鏡像發散. 任何時候,所有更改都將最終存儲在鏡像存儲庫中:
* 提交被推送到 GitLab.
* [強制更新](#forcing-an-update-core)已啟動.
推送到存儲庫中文件的更改至少會自動推送到遠程鏡像:
* 收到后五分鐘內.
* 如果啟用了**僅受鏡像保護的分支,**則在一分鐘之內.
如果分支分支不同,您將在" **鏡像存儲庫"**部分看到指示的錯誤.
### Configuring push mirrors through the API[](#configuring-push-mirrors-through-the-api "Permalink")
您還可以通過[遠程鏡像 API](../../../api/remote_mirrors.html)創建和修改項目推送鏡像.
### Push only protected branches[](#push-only-protected-branches-core "Permalink")
版本歷史
* 在[GitLab Starter](https://about.gitlab.com/pricing/) 10.3 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/3350) .
* 在 10.8 版中[移至 GitLab Core](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18715) .
您可以選擇僅將受保護的分支從 GitLab 推送到遠程存儲庫.
要使用此選項,請在創建存儲庫鏡像時選中" **僅鏡像保護的分支"**框.
### Keep divergent refs[](#keep-divergent-refs-core "Permalink")
在 GitLab 13.0 中[引入](https://gitlab.com/gitlab-org/gitlab/-/issues/208828) .
默認情況下,如果遠程鏡像上的任何引用都與本地存儲庫不同,則*整個推送*將失敗,并且不會更新任何內容.
例如,如果存儲庫具有已鏡像到遠程的`master` , `develop`和`stable`分支,然后添加新提交以在鏡像上進行`develop` ,則下一次推送嘗試將失敗,從而使`master`和`stable`不在可用范圍內約會盡管沒有分歧. 在解決分歧之前,無法反映任何分支上的更改.
啟用" **保持差異引用"**選項后,將跳過`develop`分支,從而可以更新`master`和`stable` . 鏡像狀態將反映`develop`已偏離并被跳過,并標記為更新失敗.
**注意:**創建鏡像后,當前只能通過[API](../../../api/remote_mirrors.html)修改此選項.
## Setting up a push mirror from GitLab to GitHub[](#setting-up-a-push-mirror-from-gitlab-to-github-core "Permalink")
要設置從 GitLab 到 GitHub 的鏡像,您需要執行以下步驟:
1. 創建一個[GitHub 個人訪問令牌](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) ,并選中`public_repo`框.
2. 使用以下格式填寫**Git 存儲庫 URL**字段: `https://<your_github_username>@github.com/<your_github_group>/<your_github_project>.git` .
3. 使用您的 GitHub 個人訪問令牌填寫**密碼**字段.
4. 單擊**鏡像存儲庫**按鈕.
鏡像的存儲庫將被列出. 例如, `https://*****:*****@github.com/<your_github_group>/<your_github_project>.git` .
該存儲庫將很快推送. 要強制按下,請單擊適當的按鈕.
## Setting up a push mirror to another GitLab instance with 2FA activated[](#setting-up-a-push-mirror-to-another-gitlab-instance-with-2fa-activated "Permalink")
1. 在目標 GitLab 實例上,創建一個具有`write_repository`范圍的[個人訪問令牌](../../profile/personal_access_tokens.html) .
2. 在源 GitLab 實例上:
1. 使用以下格式填寫**Git 存儲庫 URL**字段: `https://oauth2@<destination host>/<your_gitlab_group_or_name>/<your_gitlab_project>.git` .
2. 在目標 GitLab 實例上創建的 GitLab 個人訪問令牌中填寫**密碼**字段.
3. 單擊**鏡像存儲庫**按鈕.
## Pulling from a remote repository[](#pulling-from-a-remote-repository-starter "Permalink")
版本歷史
* 在 GitLab 企業版 8.2 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/51) .
* 在[GitLab Starter](https://about.gitlab.com/pricing/) 11.11 中[添加了 Git LFS 支持](https://gitlab.com/gitlab-org/gitlab/-/issues/10871) .
您可以將存儲庫設置為自動從上游存儲庫更新其分支,標記和提交.
當您感興趣的存儲庫位于其他服務器上并且您希望能夠使用熟悉的 GitLab 界面瀏覽其內容和活動時,此功能很有用.
要為現有項目配置鏡像拉出:
1. Navigate to your project’s **設置>存儲庫** and expand the **鏡像存儲庫** section.
2. 輸入存儲庫 URL.
3. 從**鏡像方向**下拉菜單中選擇**拉** .
4. 如有必要,請從" **身份驗證方法"**下拉列表中選擇一種身份**驗證方法** .
5. 如有必要,請選中以下框:
* **覆蓋分散的分支** .
* **觸發管道以更新鏡像** .
* **僅鏡像保護的分支** .
6. 單擊**鏡像存儲庫**按鈕以保存配置.
[](img/repository_mirroring_pull_settings_upper.png)
* * *
[](img/repository_mirroring_pull_settings_lower.png)
Because GitLab is now set to pull changes from the upstream repository, you should not push commits directly to the repository on GitLab. Instead, any commits should be pushed to the upstream repository. Changes pushed to the upstream repository will be pulled into the GitLab repository, either:
* 在一定時間內自動.
* 啟動[強制更新時](#forcing-an-update-core) .
**警告:**如果您確實在 GitLab 存儲庫中更新了分支,則該分支將與上游分叉,并且 GitLab 將不再自動更新該分支以防止丟失任何更改. 另請注意,上游存儲庫中已刪除的分支和標簽將不會反映在 GitLab 存儲庫中.
### How it works[](#how-it-works "Permalink")
為存儲庫啟用拉鏡像功能后,會將存儲庫添加到隊列中.
每分鐘一次,Sidekiq cron 作業基于以下內容計劃存儲庫鏡像的更新:
* 可用容量. 這由 Sidekiq 設置確定. 對于 GitLab.com,請參閱[GitLab.com Sidekiq 設置](../../gitlab_com/index.html#sidekiq) .
* 隊列中已經要更新的存儲庫鏡像數. 到期時間取決于存儲庫鏡像的最后更新時間以及重試次數.
隨著 Sidekiq 可以處理存儲庫鏡像,它們也會更新. 如果更新存儲庫鏡像的過程為:
* 成功后,至少需要等待 30 分鐘,更新才會重新加入隊列.
* 失敗(例如,分支從上游分支),稍后將再次嘗試. 鏡像最多可以發生 14 次故障,然后才不會再次進入隊列進行更新.
### SSH authentication[](#ssh-authentication "Permalink")
> * 在[GitLab Starter](https://about.gitlab.com/pricing/) 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/2551)了拉鏡像.
> * 在[GitLab Core](https://about.gitlab.com/pricing/) 11.6 中為推送鏡像[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/22982)
SSH 身份驗證是相互的:
* 您必須向服務器證明您有權訪問存儲庫.
* 服務器還必須向*您*證明它是誰.
您提供憑據作為密碼或公共密鑰. 另一個存儲庫所在的服務器提供其憑據作為"主機密鑰",其指紋需要手動驗證.
如果您通過 SSH 鏡像(即使用`ssh://` URL),則可以使用以下方法進行身份驗證:
* 基于密碼的身份驗證,就像通過 HTTPS 一樣.
* 公鑰認證. 這通常比密碼身份驗證更安全,尤其是當其他存儲庫支持[Deploy Keys 時](../../../ssh/README.html#deploy-keys) .
開始:
1. 導航到項目的**"設置">"存儲庫",**然后展開" **鏡像存儲庫"**部分.
2. 輸入`ssh://` URL 進行鏡像.
**注意:**目前不支持 SCP 樣式的 URL(即`git@example.com:group/project.git` ).
輸入 URL 在頁面上添加兩個按鈕:
* **檢測主機密鑰**.
* **手動輸入主機密鑰**.
如果單擊:
* **檢測主機密鑰**按鈕,GitLab 將從服務器獲取主機密鑰并顯示指紋.
* **手動輸入主機密鑰**按鈕,將顯示一個字段,您可以在其中粘貼主機密鑰.
假設您使用了前者,那么現在需要驗證指紋是否符合您的期望. GitLab.com 和其他代碼托管站點公開公開其指紋,供您檢查:
* [AWS CodeCommit](https://docs.aws.amazon.com/codecommit/latest/userguide/regions.html#regions-fingerprints)
* [Bitbucket](https://support.atlassian.com/bitbucket-cloud/docs/configure-ssh-and-two-step-verification/)
* [GitHub](https://help.github.com/en/github/authenticating-to-github/githubs-ssh-key-fingerprints)
* [GitLab.com](../../gitlab_com/index.html#ssh-host-keys-fingerprints)
* [Launchpad](https://help.launchpad.net/SSHFingerprints)
* [Savannah](http://savannah.gnu.org/maintenance/SshAccess/)
* [SourceForge](https://sourceforge.net/p/forge/documentation/SSH%20Key%20Fingerprints/)
其他提供者將有所不同. 如果您正在運行自我管理的 GitLab,或者可以訪問其他存儲庫的服務器,則可以安全地收集密鑰指紋:
```
$ cat /etc/ssh/ssh_host*pub | ssh-keygen -E md5 -l -f -
256 MD5:f4:28:9f:23:99:15:21:1b:bf:ed:1f:8e:a0:76:b2:9d root@example.com (ECDSA)
256 MD5:e6:eb:45:8a:3c:59:35:5f:e9:5b:80:12:be:7e:22:73 root@example.com (ED25519)
2048 MD5:3f:72:be:3d:62:03:5c:62:83:e8:6e:14:34:3a:85:1d root@example.com (RSA)
```
**注意:**對于某些舊版本的 SSH,可能需要排除`-E md5` .
在鏡像存儲庫時,GitLab 現在將在連接之前檢查至少一個存儲的主機密鑰是否匹配. 這樣可以防止將惡意代碼注入到您的鏡像中,或者防止您的密碼被盜.
### SSH public key authentication[](#ssh-public-key-authentication "Permalink")
要使用 SSH 公鑰身份驗證,您還需要從**Authentication method**下拉菜單中選擇該選項. 創建鏡像后,GitLab 會生成一個 4096 位 RSA 密鑰,可以通過單擊" **復制 SSH"公共密鑰**按鈕進行復制.
[](img/repository_mirroring_copy_ssh_public_key_button.png)
然后,您需要將公共 SSH 密鑰添加到另一個存儲庫的配置中:
* 如果其他存儲庫托管在 GitLab 上,則應將公共 SSH 密鑰添加為[Deploy Key](../../../ssh/README.html#deploy-keys) .
* 如果其他存儲庫位于其他位置,則可能需要將密鑰添加到用戶的`authorized_keys`文件中. 將整個公共 SSH 密鑰單獨粘貼到文件中并保存.
如果您需要隨時更改密鑰,則可以刪除并重新添加鏡像以生成新密鑰. 您必須使用新密鑰更新另一個存儲庫,以保持鏡像運行.
**注意:**生成的密鑰存儲在 GitLab 數據庫中,而不存儲在文件系統中. 因此,無法在預接收掛鉤中使用針對鏡像的 SSH 公鑰身份驗證.
### Overwrite diverged branches[](#overwrite-diverged-branches-starter "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/4559) in [GitLab Starter](https://about.gitlab.com/pricing/) 10.6.
您可以選擇始終使用遠程版本更新本地分支,即使它們與遠程分支不同.
**警告:**對于鏡像分支,啟用此選項會導致丟失本地更改.
要使用此選項,請在創建存儲庫鏡像時選中" **覆蓋分支分支"**框.
### Only mirror protected branches[](#only-mirror-protected-branches-starter "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/3326) in [GitLab Starter](https://about.gitlab.com/pricing/) 10.3.
您可以選擇僅將受保護的分支從遠程存儲庫拉到 GitLab. 未受保護的分支不會被鏡像,并且可能會分開.
要使用此選項,請在創建存儲庫鏡像時選中" **僅鏡像保護的分支"**框.
### Hard failure[](#hard-failure-starter "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/3117) in [GitLab Starter](https://about.gitlab.com/pricing/) 10.2.
如果鏡像過程連續 14 次失敗重試,它將被標記為硬盤失敗. 這將在以下任一位置中可見:
* 項目的主要儀表板.
* 拉鏡設置頁面.
當一個項目很難失敗時,它將不再需要進行鏡像. 用戶可以通過[強制更新來](#forcing-an-update-core)再次恢復項目鏡像.
### Trigger update using API[](#trigger-update-using-api-starter "Permalink")
[Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/3453) in [GitLab Starter](https://about.gitlab.com/pricing/) 10.3.
拉鏡像使用輪詢來檢測新添加的分支和提交,通常是在幾分鐘后. 如果您通過[API](../../../api/projects.html#start-the-pull-mirroring-process-for-a-project-starter)通知 GitLab,更新將立即被拉出.
有關更多信息,請參閱[啟動項目的拉鏡像過程](../../../api/projects.html#start-the-pull-mirroring-process-for-a-project-starter) .
## Forcing an update[](#forcing-an-update-core "Permalink")
當計劃將鏡像自動更新時,您始終可以使用" **存儲** **庫設置"**頁面的" **鏡像存儲庫"**部分上的"更新"按鈕強制進行更新.
[](img/repository_mirroring_force_update.png)
## Bidirectional mirroring[](#bidirectional-mirroring-starter "Permalink")
**注意:**雙向鏡像可能會導致沖突.
如果您將 GitLab 存儲庫配置為從同一遠程源中拉出和推送到同一遠程源,則不能保證這兩個存儲庫都將正確更新. 如果為雙向鏡像設置存儲庫,則應通過確定誰將解決它們以及如何解決它們來為可能的沖突做準備.
重寫任一遠程上的任何鏡像提交將導致沖突,并且鏡像失敗. 可以通過以下方法防止此情況:
* [Pulling only protected branches](#only-mirror-protected-branches-starter).
* [Pushing only protected branches](#push-only-protected-branches-core).
您應該[保護](../protected_branches.html)希望在兩個遠程控制器上鏡像[的分支](../protected_branches.html) ,以防止由于重寫歷史記錄而引起的沖突.
雙向鏡像還會創建競態條件,在這種競態條件中,靠近同一分支的提交會引起沖突. 通過使用[Push 事件 Webhook](../integrations/webhooks.html#push-events)觸發立即拉到 GitLab,可以通過減少鏡像延遲來緩解競爭狀況. 當僅推送鏡像受保護的分支時,來自 GitLab 的推送鏡像的速率限制為每分鐘一次.
### Configure a webhook to trigger an immediate pull to GitLab[](#configure-a-webhook-to-trigger-an-immediate-pull-to-gitlab "Permalink")
假設您已經在上游 GitLab 實例中配置了[推](#setting-up-a-push-mirror-to-another-gitlab-instance-with-2fa-activated)和[拉](#pulling-from-a-remote-repository-starter)鏡像,以觸發如上所述的立即提拉,則需要在下游實例中配置一個[推事件 Web 掛鉤](../integrations/webhooks.html#push-events) .
去做這個:
* 創建具有`API`范圍的[個人訪問令牌](../../profile/personal_access_tokens.html) .
* 導航到**設置> Webhooks**
* 添加 webhook URL,在這種情況下,它將在存儲庫更新后使用[Pull Mirror API](../../../api/projects.html#start-the-pull-mirroring-process-for-a-project-starter)請求觸發即時提取.
```
https://gitlab.example.com/api/v4/projects/:id/mirror/pull?private_token=<your_access_token>
```
* 確保已選中" **推送事件"**復選框.
* 單擊**添加 Webhook**按鈕以保存**Webhook** .
* 要測試集成,請單擊" **測試"**按鈕,并確認 GitLab 不返回任何錯誤.
### Preventing conflicts using a `pre-receive` hook[](#preventing-conflicts-using-a-pre-receive-hook "Permalink")
**警告:**提議的解決方案將對 Git 推送操作的性能產生負面影響,因為它們將被代理到上游 Git 存儲庫.
服務器端`pre-receive`掛鉤可通過僅在將提交首先推送到上游 Git 存儲庫之后才接受推送來防止上述競爭情況. 在此配置中,一個 Git 存儲庫充當權威的上游,另一個充當下游. `pre-receive`掛鉤將安裝在下游存儲庫中.
閱讀有關在 GitLab 服務器上[配置服務器掛鉤](../../../administration/server_hooks.html)的信息.
下面提供了一個樣品`pre-receive`掛鉤.
```
#!/usr/bin/env bash
# --- Assume only one push mirror target
# Push mirroring remotes are named `remote_mirror_<id>`, this finds the first remote and uses that.
TARGET_REPO=$(git remote | grep -m 1 remote_mirror)
proxy_push()
{
# --- Arguments
OLDREV=$(git rev-parse $1)
NEWREV=$(git rev-parse $2)
REFNAME="$3"
# --- Pattern of branches to proxy pushes
allowlist=$(expr "$branch" : "\(master\)")
case "$refname" in refs/heads/*)
branch=$(expr "$refname" : "refs/heads/\(.*\)")
if [ "$allowlist" = "$branch" ]; then unset GIT_QUARANTINE_PATH # handle https://git-scm.com/docs/git-receive-pack#_quarantine_environment
error="$(git push --quiet $TARGET_REPO $NEWREV:$REFNAME 2>&1)"
fail=$?
if [ "$fail" != "0" ]; then echo >&2 ""
echo >&2 " Error: updates were rejected by upstream server"
echo >&2 " This is usually caused by another repository pushing changes"
echo >&2 " to the same ref. You may want to first integrate remote changes"
echo >&2 ""
return
fi
fi
;;
esac
}
# Allow dual mode: run from the command line just like the update hook, or
# if no arguments are given then run as a hook script
if [ -n "$1" -a -n "$2" -a -n "$3" ]; then
# Output to the terminal in command line mode - if someone wanted to
# resend an email; they could redirect the output to sendmail
# themselves
PAGER= proxy_push $2 $3 $1
else
# Push is proxied upstream one ref at a time. Because of this it is possible
# for some refs to succeed, and others to fail. This will result in a failed
# push.
while read oldrev newrev refname
do proxy_push $oldrev $newrev $refname
done
fi
```
請注意,此示例有一些限制:
* 此示例可能無法完全滿足您的用例,并且可能需要進行修改.
* 它不考慮鏡像的不同類型的身份驗證機制.
* 它不適用于強制更新(重寫歷史記錄).
* 僅匹配`allowlist`模式的分支將被代理推送.
* 該腳本規避了 Git 鉤子隔離環境,因為`$TARGET_REPO`的更新被視為參考更新,Git 會對此進行抱怨.
### Mirroring with Perforce Helix via Git Fusion[](#mirroring-with-perforce-helix-via-git-fusion-starter "Permalink")
**警告:**雙向鏡像不應用作永久配置. 有關替代的遷移方法,請參閱[從 Perforce Helix](../import/perforce.html)遷移.
[Git Fusion](https://www.perforce.com/manuals/git-fusion/#Git-Fusion/section_avy_hyc_gl.html)為[Perforce Helix](https://www.perforce.com/products)提供了一個 Git 接口,GitLab 可以使用它來雙向鏡像 GitLab 項目. 從 Perforce Helix 遷移到 GitLab 的某些情況下,這可能是有用的,因為重疊的 Perforce Helix 工作區無法同時遷移到 GitLab.
如果將鏡像與 Perforce Helix 一起使用,則應僅鏡像受保護的分支. Perforce Helix 將拒絕任何重寫歷史記錄的推送. 由于 Git Fusion 的性能限制,只應鏡像最少數量的分支.
通過 Git Fusion 使用 Perforce Helix 配置鏡像時,建議使用以下 Git Fusion 設置:
* `change-pusher`應禁用. 否則,每個提交都將被重寫為由鏡像帳戶提交,而不是映射到現有的 Perforce Helix 用戶或`unknown_git`用戶.
* 如果 Perforce Helix 中不存在 GitLab 用戶,則`unknown_git`用戶將用作提交作者.
[在 Perforce.com 上](https://www.perforce.com/manuals/git-fusion/Content/Git-Fusion/section_vss_bdw_w3.html#section_zdp_zz1_3l)了解有關[Git Fusion 設置的信息](https://www.perforce.com/manuals/git-fusion/Content/Git-Fusion/section_vss_bdw_w3.html#section_zdp_zz1_3l) .
## Troubleshooting[](#troubleshooting "Permalink")
如果在推送過程中發生錯誤,則 GitLab 將在該存儲庫中顯示"錯誤"突出顯示. 然后,將鼠標懸停在突出顯示的文本上,即可查看有關錯誤的詳細信息.
### 13:Received RST_STREAM with error code 2 with GitHub[](#13received-rst_stream-with-error-code-2-with-github "Permalink")
如果在鏡像到 GitHub 存儲庫時收到"錯誤代碼為 2 的 13:Received RST_STREAM",則您的 GitHub 設置可能被設置為阻止推送,以暴露用于提交的電子郵件地址. 可以將您在 GitHub 上的電子郵件地址設置為公開,或者禁用[公開我的電子郵件](https://github.com/settings/emails)設置的" [阻止"命令行推送](https://github.com/settings/emails) .
- GitLab Docs
- Installation
- Requirements
- GitLab cloud native Helm Chart
- Install GitLab with Docker
- Installation from source
- Install GitLab on Microsoft Azure
- Installing GitLab on Google Cloud Platform
- Installing GitLab on Amazon Web Services (AWS)
- Analytics
- Code Review Analytics
- Productivity Analytics
- Value Stream Analytics
- Kubernetes clusters
- Adding and removing Kubernetes clusters
- Adding EKS clusters
- Adding GKE clusters
- Group-level Kubernetes clusters
- Instance-level Kubernetes clusters
- Canary Deployments
- Cluster Environments
- Deploy Boards
- GitLab Managed Apps
- Crossplane configuration
- Cluster management project (alpha)
- Kubernetes Logs
- Runbooks
- Serverless
- Deploying AWS Lambda function using GitLab CI/CD
- Securing your deployed applications
- Groups
- Contribution Analytics
- Custom group-level project templates
- Epics
- Manage epics
- Group Import/Export
- Insights
- Issues Analytics
- Iterations
- Public access
- SAML SSO for GitLab.com groups
- SCIM provisioning using SAML SSO for GitLab.com groups
- Subgroups
- Roadmap
- Projects
- GitLab Secure
- Security Configuration
- Container Scanning
- Dependency Scanning
- Dependency List
- Static Application Security Testing (SAST)
- Secret Detection
- Dynamic Application Security Testing (DAST)
- GitLab Security Dashboard
- Offline environments
- Standalone Vulnerability pages
- Security scanner integration
- Badges
- Bulk editing issues and merge requests at the project level
- Code Owners
- Compliance
- License Compliance
- Compliance Dashboard
- Create a project
- Description templates
- Deploy Keys
- Deploy Tokens
- File finder
- Project integrations
- Integrations
- Atlassian Bamboo CI Service
- Bugzilla Service
- Custom Issue Tracker service
- Discord Notifications service
- Enabling emails on push
- GitHub project integration
- Hangouts Chat service
- Atlassian HipChat
- Irker IRC Gateway
- GitLab Jira integration
- Mattermost Notifications Service
- Mattermost slash commands
- Microsoft Teams service
- Mock CI Service
- Prometheus integration
- Redmine Service
- Slack Notifications Service
- Slack slash commands
- GitLab Slack application
- Webhooks
- YouTrack Service
- Insights
- Issues
- Crosslinking Issues
- Design Management
- Confidential issues
- Due dates
- Issue Boards
- Issue Data and Actions
- Labels
- Managing issues
- Milestones
- Multiple Assignees for Issues
- Related issues
- Service Desk
- Sorting and ordering issue lists
- Issue weight
- Associate a Zoom meeting with an issue
- Merge requests
- Allow collaboration on merge requests across forks
- Merge Request Approvals
- Browser Performance Testing
- How to create a merge request
- Cherry-pick changes
- Code Quality
- Load Performance Testing
- Merge Request dependencies
- Fast-forward merge requests
- Merge when pipeline succeeds
- Merge request conflict resolution
- Reverting changes
- Reviewing and managing merge requests
- Squash and merge
- Merge requests versions
- Draft merge requests
- Members of a project
- Migrating projects to a GitLab instance
- Import your project from Bitbucket Cloud to GitLab
- Import your project from Bitbucket Server to GitLab
- Migrating from ClearCase
- Migrating from CVS
- Import your project from FogBugz to GitLab
- Gemnasium
- Import your project from GitHub to GitLab
- Project importing from GitLab.com to your private GitLab instance
- Import your project from Gitea to GitLab
- Import your Jira project issues to GitLab
- Migrating from Perforce Helix
- Import Phabricator tasks into a GitLab project
- Import multiple repositories by uploading a manifest file
- Import project from repo by URL
- Migrating from SVN to GitLab
- Migrating from TFVC to Git
- Push Options
- Releases
- Repository
- Branches
- Git Attributes
- File Locking
- Git file blame
- Git file history
- Repository mirroring
- Protected branches
- Protected tags
- Push Rules
- Reduce repository size
- Signing commits with GPG
- Syntax Highlighting
- GitLab Web Editor
- Web IDE
- Requirements Management
- Project settings
- Project import/export
- Project access tokens (Alpha)
- Share Projects with other Groups
- Snippets
- Static Site Editor
- Wiki
- Project operations
- Monitor metrics for your CI/CD environment
- Set up alerts for Prometheus metrics
- Embedding metric charts within GitLab-flavored Markdown
- Embedding Grafana charts
- Using the Metrics Dashboard
- Dashboard YAML properties
- Metrics dashboard settings
- Panel types for dashboards
- Using Variables
- Templating variables for metrics dashboards
- Prometheus Metrics library
- Monitoring AWS Resources
- Monitoring HAProxy
- Monitoring Kubernetes
- Monitoring NGINX
- Monitoring NGINX Ingress Controller
- Monitoring NGINX Ingress Controller with VTS metrics
- Alert Management
- Error Tracking
- Tracing
- Incident Management
- GitLab Status Page
- Feature Flags
- GitLab CI/CD
- GitLab CI/CD pipeline configuration reference
- GitLab CI/CD include examples
- Introduction to CI/CD with GitLab
- Getting started with GitLab CI/CD
- How to enable or disable GitLab CI/CD
- Using SSH keys with GitLab CI/CD
- Migrating from CircleCI
- Migrating from Jenkins
- Auto DevOps
- Getting started with Auto DevOps
- Requirements for Auto DevOps
- Customizing Auto DevOps
- Stages of Auto DevOps
- Upgrading PostgreSQL for Auto DevOps
- Cache dependencies in GitLab CI/CD
- GitLab ChatOps
- Cloud deployment
- Docker integration
- Building Docker images with GitLab CI/CD
- Using Docker images
- Building images with kaniko and GitLab CI/CD
- GitLab CI/CD environment variables
- Predefined environment variables reference
- Where variables can be used
- Deprecated GitLab CI/CD variables
- Environments and deployments
- Protected Environments
- GitLab CI/CD Examples
- Test a Clojure application with GitLab CI/CD
- Using Dpl as deployment tool
- Testing a Phoenix application with GitLab CI/CD
- End-to-end testing with GitLab CI/CD and WebdriverIO
- DevOps and Game Dev with GitLab CI/CD
- Deploy a Spring Boot application to Cloud Foundry with GitLab CI/CD
- How to deploy Maven projects to Artifactory with GitLab CI/CD
- Testing PHP projects
- Running Composer and NPM scripts with deployment via SCP in GitLab CI/CD
- Test and deploy Laravel applications with GitLab CI/CD and Envoy
- Test and deploy a Python application with GitLab CI/CD
- Test and deploy a Ruby application with GitLab CI/CD
- Test and deploy a Scala application to Heroku
- GitLab CI/CD for external repositories
- Using GitLab CI/CD with a Bitbucket Cloud repository
- Using GitLab CI/CD with a GitHub repository
- GitLab Pages
- GitLab Pages
- GitLab Pages domain names, URLs, and baseurls
- Create a GitLab Pages website from scratch
- Custom domains and SSL/TLS Certificates
- GitLab Pages integration with Let's Encrypt
- GitLab Pages Access Control
- Exploring GitLab Pages
- Incremental Rollouts with GitLab CI/CD
- Interactive Web Terminals
- Optimizing GitLab for large repositories
- Metrics Reports
- CI/CD pipelines
- Pipeline Architecture
- Directed Acyclic Graph
- Multi-project pipelines
- Parent-child pipelines
- Pipelines for Merge Requests
- Pipelines for Merged Results
- Merge Trains
- Job artifacts
- Pipeline schedules
- Pipeline settings
- Triggering pipelines through the API
- Review Apps
- Configuring GitLab Runners
- GitLab CI services examples
- Using MySQL
- Using PostgreSQL
- Using Redis
- Troubleshooting CI/CD
- GitLab Package Registry
- GitLab Container Registry
- Dependency Proxy
- GitLab Composer Repository
- GitLab Conan Repository
- GitLab Maven Repository
- GitLab NPM Registry
- GitLab NuGet Repository
- GitLab PyPi Repository
- API Docs
- API resources
- .gitignore API
- GitLab CI YMLs API
- Group and project access requests API
- Appearance API
- Applications API
- Audit Events API
- Avatar API
- Award Emoji API
- Project badges API
- Group badges API
- Branches API
- Broadcast Messages API
- Project clusters API
- Group clusters API
- Instance clusters API
- Commits API
- Container Registry API
- Custom Attributes API
- Dashboard annotations API
- Dependencies API
- Deploy Keys API
- Deployments API
- Discussions API
- Dockerfiles API
- Environments API
- Epics API
- Events
- Feature Flags API
- Feature flag user lists API
- Freeze Periods API
- Geo Nodes API
- Group Activity Analytics API
- Groups API
- Import API
- Issue Boards API
- Group Issue Boards API
- Issues API
- Epic Issues API
- Issues Statistics API
- Jobs API
- Keys API
- Labels API
- Group Labels API
- License
- Licenses API
- Issue links API
- Epic Links API
- Managed Licenses API
- Markdown API
- Group and project members API
- Merge request approvals API
- Merge requests API
- Project milestones API
- Group milestones API
- Namespaces API
- Notes API
- Notification settings API
- Packages API
- Pages domains API
- Pipeline schedules API
- Pipeline triggers API
- Pipelines API
- Project Aliases API
- Project import/export API
- Project repository storage moves API
- Project statistics API
- Project templates API
- Projects API
- Protected branches API
- Protected tags API
- Releases API
- Release links API
- Repositories API
- Repository files API
- Repository submodules API
- Resource label events API
- Resource milestone events API
- Resource weight events API
- Runners API
- SCIM API
- Search API
- Services API
- Application settings API
- Sidekiq Metrics API
- Snippets API
- Project snippets
- Application statistics API
- Suggest Changes API
- System hooks API
- Tags API
- Todos API
- Users API
- Project-level Variables API
- Group-level Variables API
- Version API
- Vulnerabilities API
- Vulnerability Findings API
- Wikis API
- GraphQL API
- Getting started with GitLab GraphQL API
- GraphQL API Resources
- API V3 to API V4
- Validate the .gitlab-ci.yml (API)
- User Docs
- Abuse reports
- User account
- Active sessions
- Deleting a User account
- Permissions
- Personal access tokens
- Profile preferences
- Threads
- GitLab and SSH keys
- GitLab integrations
- Git
- GitLab.com settings
- Infrastructure as code with Terraform and GitLab
- GitLab keyboard shortcuts
- GitLab Markdown
- AsciiDoc
- GitLab Notification Emails
- GitLab Quick Actions
- Autocomplete characters
- Reserved project and group names
- Search through GitLab
- Advanced Global Search
- Advanced Syntax Search
- Time Tracking
- GitLab To-Do List
- Administrator Docs
- Reference architectures
- Reference architecture: up to 1,000 users
- Reference architecture: up to 2,000 users
- Reference architecture: up to 3,000 users
- Reference architecture: up to 5,000 users
- Reference architecture: up to 10,000 users
- Reference architecture: up to 25,000 users
- Reference architecture: up to 50,000 users
- Troubleshooting a reference architecture set up
- Working with the bundled Consul service
- Configuring PostgreSQL for scaling
- Configuring GitLab application (Rails)
- Load Balancer for multi-node GitLab
- Configuring a Monitoring node for Scaling and High Availability
- NFS
- Working with the bundled PgBouncer service
- Configuring Redis for scaling
- Configuring Sidekiq
- Admin Area settings
- Continuous Integration and Deployment Admin settings
- Custom instance-level project templates
- Diff limits administration
- Enable and disable GitLab features deployed behind feature flags
- Geo nodes Admin Area
- GitLab Pages administration
- Health Check
- Job logs
- Labels administration
- Log system
- PlantUML & GitLab
- Repository checks
- Repository storage paths
- Repository storage types
- Account and limit settings
- Service templates
- System hooks
- Changing your time zone
- Uploads administration
- Abuse reports
- Activating and deactivating users
- Audit Events
- Blocking and unblocking users
- Broadcast Messages
- Elasticsearch integration
- Gitaly
- Gitaly Cluster
- Gitaly reference
- Monitoring GitLab
- Monitoring GitLab with Prometheus
- Performance Bar
- Usage statistics
- Object Storage
- Performing Operations in GitLab
- Cleaning up stale Redis sessions
- Fast lookup of authorized SSH keys in the database
- Filesystem Performance Benchmarking
- Moving repositories managed by GitLab
- Run multiple Sidekiq processes
- Sidekiq MemoryKiller
- Switching to Puma
- Understanding Unicorn and unicorn-worker-killer
- User lookup via OpenSSH's AuthorizedPrincipalsCommand
- GitLab Package Registry administration
- GitLab Container Registry administration
- Replication (Geo)
- Geo database replication
- Geo with external PostgreSQL instances
- Geo configuration
- Using a Geo Server
- Updating the Geo nodes
- Geo with Object storage
- Docker Registry for a secondary node
- Geo for multiple nodes
- Geo security review (Q&A)
- Location-aware Git remote URL with AWS Route53
- Tuning Geo
- Removing secondary Geo nodes
- Geo data types support
- Geo Frequently Asked Questions
- Geo Troubleshooting
- Geo validation tests
- Disaster Recovery (Geo)
- Disaster recovery for planned failover
- Bring a demoted primary node back online
- Automatic background verification
- Rake tasks
- Back up and restore GitLab
- Clean up
- Namespaces
- Maintenance Rake tasks
- Geo Rake Tasks
- GitHub import
- Import bare repositories
- Integrity check Rake task
- LDAP Rake tasks
- Listing repository directories
- Praefect Rake tasks
- Project import/export administration
- Repository storage Rake tasks
- Generate sample Prometheus data
- Uploads migrate Rake tasks
- Uploads sanitize Rake tasks
- User management
- Webhooks administration
- X.509 signatures
- Server hooks
- Static objects external storage
- Updating GitLab
- GitLab release and maintenance policy
- Security
- Password Storage
- Custom password length limits
- Restrict allowed SSH key technologies and minimum length
- Rate limits
- Webhooks and insecure internal web services
- Information exclusivity
- How to reset your root password
- How to unlock a locked user from the command line
- User File Uploads
- How we manage the TLS protocol CRIME vulnerability
- User email confirmation at sign-up
- Security of running jobs
- Proxying assets
- CI/CD Environment Variables
- Contributor and Development Docs
- Contribute to GitLab
- Community members & roles
- Implement design & UI elements
- Issues workflow
- Merge requests workflow
- Code Review Guidelines
- Style guides
- GitLab Architecture Overview
- CI/CD development documentation
- Database guides
- Database Review Guidelines
- Database Review Guidelines
- Migration Style Guide
- What requires downtime?
- Understanding EXPLAIN plans
- Rake tasks for developers
- Mass inserting Rails models
- GitLab Documentation guidelines
- Documentation Style Guide
- Documentation structure and template
- Documentation process
- Documentation site architecture
- Global navigation
- GitLab Docs monthly release process
- Telemetry Guide
- Usage Ping Guide
- Snowplow Guide
- Experiment Guide
- Feature flags in development of GitLab
- Feature flags process
- Developing with feature flags
- Feature flag controls
- Document features deployed behind feature flags
- Frontend Development Guidelines
- Accessibility & Readability
- Ajax
- Architecture
- Axios
- Design Patterns
- Frontend Development Process
- DropLab
- Emojis
- Filter
- Frontend FAQ
- GraphQL
- Icons and SVG Illustrations
- InputSetter
- Performance
- Principles
- Security
- Tooling
- Vuex
- Vue
- Geo (development)
- Geo self-service framework (alpha)
- Gitaly developers guide
- GitLab development style guides
- API style guide
- Go standards and style guidelines
- GraphQL API style guide
- Guidelines for shell commands in the GitLab codebase
- HTML style guide
- JavaScript style guide
- Migration Style Guide
- Newlines style guide
- Python Development Guidelines
- SCSS style guide
- Shell scripting standards and style guidelines
- Sidekiq debugging
- Sidekiq Style Guide
- SQL Query Guidelines
- Vue.js style guide
- Instrumenting Ruby code
- Testing standards and style guidelines
- Flaky tests
- Frontend testing standards and style guidelines
- GitLab tests in the Continuous Integration (CI) context
- Review Apps
- Smoke Tests
- Testing best practices
- Testing levels
- Testing Rails migrations at GitLab
- Testing Rake tasks
- End-to-end Testing
- Beginner's guide to writing end-to-end tests
- End-to-end testing Best Practices
- Dynamic Element Validation
- Flows in GitLab QA
- Page objects in GitLab QA
- Resource class in GitLab QA
- Style guide for writing end-to-end tests
- Testing with feature flags
- Translate GitLab to your language
- Internationalization for GitLab
- Translating GitLab
- Proofread Translations
- Merging translations from CrowdIn
- Value Stream Analytics development guide
- GitLab subscription
- Activate GitLab EE with a license