首页 > 其他分享 >git-download-MR

git-download-MR

时间:2023-07-13 16:22:33浏览次数:45  
标签:head git hint refs merge MR download requests

1.查看MR

使用git ls-remote查看提交MR(merge-requests)

git ls-remote | grep "refs/merge-requests"| head -n 10
From gitlab.xxx:xxx/build.git
79c4f50d45d7cc7df48e1551ab8d42abc8b7e6f0        refs/merge-requests/10002543/head
b9075545816b5d4d4e55698ac341f9ac75c5702e        refs/merge-requests/10002669/head
39dc1827c978baa7087ff6d2ce2a058d22b632ae        refs/merge-requests/10011925/head
73f67a99299de96239e647a3953011c51dfea600        refs/merge-requests/10023861/head
545f7241c3254bbbef6bcff798599b45fc15a156        refs/merge-requests/10028253/head
3b0e2e1c504faeb7d6caa26557ea4b5db72e8624        refs/merge-requests/10029241/head
de755428fdb713a7967b06fef915c91ac66ec713        refs/merge-requests/10029896/head
43d42ed76255c935464e7bb6a4a406e75422eb74        refs/merge-requests/10033744/head
53f7405948cf249488d1f3ae1fa0263a19c57754        refs/merge-requests/10036465/head
0d27b0fa55fe13df078aeff1cda7927c655173c2        refs/merge-requests/10045142/head

2.下载MR

2-1.下载到当前分支

使用该方式拉取会有冲突的问题

2-1-1.案列一

git pull=git fetch+git merge

拉取MR代码

git pull origin refs/merge-requests/10002543/head
From gitlab.xxx:xxx/build
 * branch              refs/merge-requests/10002543/head -> FETCH_HEAD
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint: 
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
Auto-merging jenkins/controller.py
CONFLICT (content): Merge conflict in jenkins/controller.py
Automatic merge failed; fix conflicts and then commit the result.

查看状态

git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   jenkins/controller.py

no changes added to commit (use "git add" and/or "git commit -a")

2-1-2.案列二

案例二本质就是案列一的分部操作

拉取MR代码到FETCH_HEAD

git fetch origin refs/merge-requests/10002543/head
From gitlab.xxx:xxx/build
 * branch              refs/merge-requests/10002543/head -> FETCH_HEAD

合并(FETCH_HEAD)

git merge FETCH_HEAD
Auto-merging jenkins/controller/jenkins_cluster_controller.py
CONFLICT (content): Merge conflict in jenkins/controller/jenkins_cluster_controller.py
Automatic merge failed; fix conflicts and then commit the result.

查看状态

git status
On branch master
You have unmerged paths.
  (fix conflicts and run "git commit")
  (use "git merge --abort" to abort the merge)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   jenkins/controller.py

no changes added to commit (use "git add" and/or "git commit -a")

2-1-3.案列三

拉取MR代码到FETCH_HEAD

git fetch origin refs/merge-requests/10002543/head
From gitlab.xxx:xxx/build
 * branch              refs/merge-requests/10002543/head -> FETCH_HEAD

cherry-pick(FETCH_HEAD)

git cherr-pick FETCH_HEAD
Auto-merging jenkins/controller.py
CONFLICT (content): Merge conflict in jenkins/controller.py
error: could not apply 79c4f50d... Fix check machine status
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

查看状态

git status
On branch master
You are currently cherry-picking commit 79c4f50d.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
        both modified:   jenkins/controller.py

no changes added to commit (use "git add" and/or "git commit -a")

2-2.下载到新分支上

下载对应的mr(10002543),并且新建一个abc分支,没有冲突的问题

git pull origin refs/merge-requests/<MR-id>/head:<new_branch>

git pull origin refs/merge-requests/10002543/head:abc
emote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 24.30 KiB | 1.28 MiB/s, done.
From gitlab.xxx:xxx/build
 ! [rejected]          refs/merge-requests/10002543/head -> abc  (non-fast-forward)

标签:head,git,hint,refs,merge,MR,download,requests
From: https://www.cnblogs.com/lxd670/p/17551246.html

相关文章

  • gitlab与LDAP 联调
    gitlab整理目录gitlab整理1.安装Gitlab依赖包2.下载,安装3.配置,访问域名及邮箱4.初始化,启动5.访问,以及邮箱测试5.1汉化6.问题总结处理6.1安装时出现7.ssl8.升级9.备份补充10.git创建公钥与基础配置11.gitlab镜像仓库配置文件1.安装Gitlab依赖包#系统要求Ubuntu(16.04/18.0......
  • 清理.git文件夹过大出现臃肿问题-filter-branch和BFG工具
    Git开发手册git一些不常用的命令记不住,可以查看git开发手册(https://m.php.cn/manual/view/34957.html)1、.git/objects/pack文件过大今天从git拉取项目进行开发的时候克隆的很慢,还以为是网速的问题。查看了一些git命令框的拉取网络速度发现网速也很快,克隆下来后才发现是.git文......
  • 处理.git文件夹过大出现臃肿问题-filter-branch和BFG工具
    Git开发手册git一些不常用的命令记不住,可以查看git开发手册(https://m.php.cn/manual/view/34957.html)1、.git/objects/pack文件过大今天从git拉取项目进行开发的时候克隆的很慢,还以为是网速的问题。查看了一些git命令框的拉取网络速度发现网速也很快,克隆下来后才发现是.git文......
  • git-diff
    1.diff说明用于比较两次修改的差异1-1.参数参数描述–cached显示暂存区(已add但未commit文件)和最后一次commit(HEAD)之间差异。–staged同--cached。–stat查看简单的diff比较结果。1-2.改动范围说明@@-l,s+l,s@@:其中l是起始行号,s是......
  • git-tag
    1.tag简介1-1.说明tag就是对某次commit的一个标识,相当于起了一个别名创建的标签会在.git/refs/tags下1-1-1.查看tags目录ls.git/refs/tagsv1.0.0v2.0.01-1-2.查看tags下的标签文件cat.git/refs/tags/v1.0.0f3d2540bdaf36e6b0092ccd0d3aa908c19f2f7081-2.ta......
  • git-worktree
    1.说明git-worktreegitworktree非常适合大型项目又需要维护多个分支,想要避免来回切换的情况优点gitworktree可以快速进行并行开发,同一个项目多个分支同时并行演进gitworktree的提交可以在同一个项目中共享gitworktree和单独clone项目相比,节省了硬盘空间,......
  • Git 基础入门
    Git基础入门一、安装与配置1.下载安装https://git-scm.com/download/ 2.使用入口win:右键菜单—gitbashmac:终端窗口 3.基础配置a.首次使用添加身份说明,使用以下两个命令:$gitconfig--globaluser.name"你的昵称"$gitconfig--globaluser.email邮箱 b.......
  • 常用gitignore
    #file.build.cmake-build-debug.idea#Prerequisites*.d#CompiledObjectfiles*.slo*.lo*.o*.obj#PrecompiledHeaders*.gch*.pch#CompiledDynamiclibraries*.so*.dylib*.dll#Fortranmodulefiles*.mod*.smod#CompiledStaticlibraries*.lai*.la*.a*.lib#......
  • 如何实现r语言做logit回归的具体操作步骤
    R语言做Logit回归Logit回归是一种常用的统计分析方法,可以用来研究二元分类问题。它可以对因变量的概率进行建模,并利用自变量的线性组合来预测分类结果。本文将介绍如何使用R语言进行Logit回归分析,并给出相应的代码示例。数据准备首先,我们需要准备用于Logit回归分析的数据。考虑......
  • Git备忘录
    环境:Windows安装Git下载地址:https://git-scm.com/download配置Git安装完成后需要配置,开始菜单打开“GitCMD”或右键打开“OpenGitBashhere”。配置用户名和提交用到的邮箱#配置用户名gitconfig--globaluser.name"xxx"#配置邮箱gitconfig--globaluser.email......