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