簡體   English   中英

Git 獲取標簽但缺少最新版本

[英]Git fetch tags but missing latest version

最近我升級了我的 gitlab( 8.17.3 -> 12.10.9 )。 升級git后一切正常。

但有時,某些項目無法獲取完整標簽(缺少最新版本)。 使用 jenkins 時,錯誤消息是“找不到要構建的任何修訂。驗證此作業的存儲庫和分支配置”。

git 客戶端版本為:1.7.1.2、1.8.3.1、2.8.4 和 2.22.0

如何重現:

git init test ;
cd test ;
git fetch --tags --progress http://url_to_git/abc.git "+refs/heads/*:refs/remotes/origin/*"  --prune

...
From From http://url_to_git/abc.gi
 * [new branch]      Dev_Long_Br -> origin/Dev_Long_Br
 * [new branch]      ft_dev_0805_ppt -> origin/ft_dev_0805_ppt
 * [new branch]      ft_dev_0911 -> origin/ft_dev_0911
 * [new branch]      master     -> origin/master
 * [new tag]         dev_fiba_dmm_20190302_1028 -> dev_fiba_dmm_20190302_1028
 * [new tag]         rls_fiba_dmm_20191126 -> rls_fiba_dmm_20191126

結果似乎缺少最新的分支“rls_0929”。 但是等一會兒再試取標簽,我得到了最新的分支

git fetch --tags --progress http://url_to_git/abc.git "+refs/heads/*:refs/remotes/origin/*"  --
...
 From http://url_to_git/abc.git
   7501d7d..1a9a602  ft_dev_0911 -> origin/ft_dev_0911
 * [new branch]      rls_0929   -> origin/rls_0929

如果我刪除.git目錄,重新fetch tags ,一切似乎都是正確的。

工作步驟如下:

rm -rf .git
retry fetch
git init; git fetch --tags --progress http://url_to_git/abc.git "+refs/heads/*:refs/remotes/origin/*"  --prune
...

 From From http://url_to_git/abc.gi
 * [new branch]      Dev_Long_Br -> origin/Dev_Long_Br
 * [new branch]      ft_dev_0805_ppt -> origin/ft_dev_0805_ppt
 * [new branch]      ft_dev_0911 -> origin/ft_dev_0911
 * [new branch]      master     -> origin/master
 * [new branch]      rls_0929   -> origin/rls_0929
 * [new tag]         dev_fiba_dmm_20190302_1028 -> dev_fiba_dmm_20190302_1028
 * [new tag]         rls_fiba_dmm_20191126 -> rls_fiba_dmm_20191126

我用nfs作為存儲服務,是不是存儲緩存問題 nfs server info:

 # rpm -qa|grep nfs
libnfsidmap-0.25-15.el7.x86_64
nfs-utils-1.3.0-0.33.el7_3.x86_64
[root@gitpprdtools-prod34 ~]# service nfs status
Redirecting to /bin/systemctl status  nfs.service
● nfs-server.service - NFS server and services
   Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; enabled; vendor preset: disabled)
   Active: active (exited) since Sat 2020-07-18 00:14:18 CST; 2 months 12 days ago
 Main PID: 16701 (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/nfs-server.service

NFS 客戶端/gitlab 應用程序服務器信息:

mount|grep git-data
NFS_IP:/var/opt/gitlab/git-data on /var/opt/gitlab/git-data type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,soft,proto=tcp,timeo=600,retrans=2,sec=
sys,mountaddr=NFS_IP,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=NFS_IP)

該分支實際存在於遠程 git 服務器上。 我懷疑這是一個 nfs 問題,我的 git 服務器是 4 個 git 應用程序服務器,具有一個 vip 並安裝相同的 nfs 存儲。 發生錯誤時,客戶端真正請求的git服務器具有沒有最新分支的nfs緩存。 所以我將我的設置修改為 git doc,但錯誤繼續https://docs.gitlab.com/12.10/ee/administration/high_availability/nfs.html

jenkins specify branch to build時出現missing lastest branch錯誤,錯誤如下:

Started from command line by jenkinsadmin
Building remotely on docker10-2.64 (C++ docker10 docker) in workspace /data/jenkins/workspace/workspace/Flow_dockerMakePackage_5387053_774
Cloning the remote Git repository
Cloning repository http://git.a.com/b/c.git
 > git init /data/jenkins/workspace/workspace/Flow_dockerMakePackage_5387053_774 # timeout=10
Fetching upstream changes from http://git.a.com/b/c.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials root_gitlab
 > git fetch --tags --progress http://git.a.com/b/c.git +refs/heads/*:refs/remotes/origin/* # timeout=30
 > git config remote.origin.url http://git.a.com/b/c.git # timeout=10
 > git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git config remote.origin.url http://git.a.com/b/c.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
 > git clean -fdx # timeout=10
Pruning obsolete local branches
Fetching upstream changes from http://git.a.com/b/c.git
using GIT_ASKPASS to set credentials root_gitlab
 > git fetch --tags --progress http://git.a.com/b/c.git +refs/heads/*:refs/remotes/origin/* --prune # timeout=30
 > git rev-parse b215fc6cf5a4f431408773e3e05130a72f263546^{commit} # timeout=10
 > git rev-parse origin/b215fc6cf5a4f431408773e3e05130a72f263546^{commit} # timeout=10
 > git rev-parse b215fc6cf5a4f431408773e3e05130a72f263546^{commit} # timeout=10
ERROR: Couldn't find any revision to build. Verify the repository and branch configuration for this job.

誰能幫忙?

您用rls_0929分支描述了 git 的正常行為,該分支最初在遙控器上不存在,並且是在您的 2 git fetch調用之間創建的。

是什么因素讓你產生了不同的想法?

要查看您期望的分支是否確實存在於您的遙控器上,請檢查其內容:

  • 通過 gitlab 的 GUI(你標記gitlab因為你的遙控器是一個 gitlab 實例,對嗎?)
  • 來自 cli: git ls-remote <url> refs/heads/rls_0929

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM