Azure Data Factory Git合并Main到Feature

huangapple go评论76阅读模式
英文:

Azure Data Factory Git Merge Main into Feature

问题

I'm working on Azure Data Factory as part of a large team and hitting a problem managing merges which does not seem to make sense.

场景
在启动新功能时,我们会创建一个名为“feature-001”的新分支,例如,基于“main”。然后,我们只添加新功能所需的内容到该分支以满足新功能的需求,然后将PR提交到Azure DevOps Git。

不时会检测到合并冲突。解决此问题的建议是进入VSCode并执行以下操作以解决冲突:

克隆存储库(拉取最新的“main”)。

验证远程的feature-001分支是否存在:

git branch -r

显然是存在的:

PS G:\azure\adf\adf-arm> git branch -r
  origin/HEAD -> origin/main
  origin/feature-001
  origin/main

然后执行:


PS G:\azure\adf\adf-arm> git switch feature-001   
Switched to a new branch ‘feature-001’
Branch ‘feature-001’ set up to track remote branch ‘feature-001’ from ‘origin’.

这会创建一个本地分支“feature-001”,以跟踪上游分支,我们可以在其中解决冲突。

接下来,为了查看冲突的位置,建议尝试将“main”合并到“feature-001”分支中:

git merge main

这个想法是阻止“feature-001”合并到“main”的任何东西都将与阻止“main”合并到“feature-001”的内容相同。这样,我们可以在VSCode中解决合并冲突,但是在“feature-001”分支上。

然后,当解决完毕后,应该将修复后的分支推送回远程的feature-001分支。当它被推送回来时,Azure DevOps会检测到更改,重新评估PR,并意识到现在没有合并冲突,可以轻松完成PR。这似乎是一个明智的策略,因为它将任何混乱都远离“main”,并确保只有没有合并冲突(或已修复)的提交会被Azure DevOps合并到“main”。

我看到的问题是,当我设置好一切并执行:

git merge main

我得到了

G:\azure\adf\adf-arm> git merge main  
Already up to date.

这对我来说毫无意义,因为明显我在“feature-001”中有更改,而在“main”中没有。它们甚至没有相同的提交ID:

PS G:\azure\adf\adf-arm> git branch -vv
* feature-001 8cc623c [origin/feature-001] Adding pipeline: f001-pipeline
  main        1304c11 [origin/main] Update publish_config.json

我知道git会告诉我正确的事情,但我看不出是什么原因。可以有善心的人 enlighten me ... 么?

英文:

I'm working on Azure Data Factory as part of a large team and hitting a problem managing merges which does not seem to make sense.

Scenario
When starting a new feature we create a new branch called, for example, 'feature-001' based off 'main'. We then add only what is needed to that branch to satisfy the new feature then submit a PR to Azure DevOps Git.

From time to time there will be a merge conflict detected. The advice given to resolve this is to go into VSCode and resolve the conflict by doing the following:

Clone down the repo (which pulls down the latest 'main').

Verify that the remote feature-001 branch is there with a

git branch -r

Which it (obviously) is:

PS G:\azure\adf\adf-arm> git branch -r
  origin/HEAD -> origin/main
  origin/feature-001
  origin/main

Then to do a:


PS G:\azure\adf\adf-arm> git switch feature-001   
Switched to a new branch 'feature-001'
Branch 'feature-001' set up to track remote branch 'feature-001' from 'origin'.

This creates a local branch 'feature-001', tracking to the upstream, where we are to resolve the conflicts.

Next, in order to see where the conflicts are we are advised to attempt to merge 'main' into the 'feature-001' branch with:

git merge main

The idea is that whatever was preventing 'feature-001' from being merged into 'main' is going to be identical to whatever prevents 'main' from being merged into 'feature-001'. This way we can resolve the merge conflict right there in VSCode but ON the 'feature-001' branch.

Then, when resolved, we should push the fixed branch back to the remote/feature-001 branch. When it's pushed back, Azure DevOps detects the change, re-evaluates the PR and realises that there are now no merge conflicts and the PR can be completed painlessly. This seem like a sensible strategy as it keeps any messiness away from 'main'and ensures that only merge-conflict free (or fixed) commits are merged into 'main' by Azure DevOps.

The problem I am seeing is that when I have set everything up and I do:

git merge main

I get

G:\azure\adf\adf-arm> git merge main  
Already up to date.

This does not make sense to me as clearly I have changes in 'feature-001' which are not in 'main'. They don't even have the same commit id:

PS G:\azure\adf\adf-arm> git branch -vv
* feature-001 8cc623c [origin/feature-001] Adding pipeline: f001-pipeline
  main        1304c11 [origin/main] Update publish_config.json

I know that git will be telling me the correct thing and that I'm missing something, but I can't see what it is. Can some kind soul enlighten me ... please!

答案1

得分: 2

Already up to date消息会在你尝试将主分支中已存在于你的特性分支中的更改合并时出现。我可以想到两种情况可能会发生:

  1. 自从你创建特性分支以来,主分支没有发生任何更改。但在这种情况下,你不会遇到合并冲突,所以这似乎不是你的情况。

  2. 最新的主分支更改尚未在本地拉取。当你运行 git merge master 时,你操作的是本地主分支。如果最新的更改尚未从远程主分支拉取,你将不会遇到合并冲突。

我倾向于认为你面对的是第二种情况。在运行 git merge master 之前,运行 git pull 以从远程拉取最新更改。

英文:

The Already up to date message shows up when you try to merge the changes in master which are already in your feature branch. I can think of two cases when this can happen:

  1. There were no changes to the master branch since you branched out your feature branch. However, in this case you won't face with the merge conflicts, so it doesn't seem to be your case.

  2. The latest changes of master have not been pulled locally. When you run git merge master it's the local master you operate with. If the latest changes were not pulled from the origin master, you'll not witness those merge conflicts.

I tend to think you face with the case #2. Before doing git merge master run git pull to pull the most recent changes from the remote.

huangapple
  • 本文由 发表于 2023年5月13日 17:07:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76241926.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定