这对我来说似乎并不罕见(因为当我确实需要重写历史记录时经常会发生这种情况,幸运的是这种情况很少见)。与在另一个分支上重新部署不同,在手动解决冲突后,冲突似乎无法解决(它们会在以后的提交中再次发生)。此外,为什么会发生这种情况是一个谜:
我试图添加一个新的提交,然后通过更改已移动的提交的pick
-> fixup
将其移到历史记录的较早位置。与此更改相关的所有内容以及围绕这些更改的所有提交似乎都很好,所以我认为这不是问题所在(同样,我刚刚在另一个存储库中成功执行了相同的过程,并且在过去做其他程序时)。问题似乎与重演历史本身有关。这是一个示例:
$ git rebase --continue
Auto-merging services-core/src/main/java/edu/ncrn/cornell/service/CodebookService.scala
CONFLICT (content): Merge conflict in services-core/src/main/java/edu/ncrn/cornell/service/CodebookService.scala
error: could not apply a2fbc99... refactored details service return types, added pagination calls for var list services
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply a2fbc99... refactored details service return types, added pagination calls for var list services
brandon@beb82dell0-DevContainer:~/workspace/ced2ar-core-services
$ git status
interactive rebase in progress; onto f3bd89d
Last commands done (97 commands done):
pick 1228f8d fixing pom (which was fixed, but didn't make it into last few commits)
pick a2fbc99 refactored details service return types, added pagination calls for var list services
(see more in file .git/rebase-merge/done)
Next commands to do (23 remaining commands):
pick 1b686a9 cleaned up codebookservice file
pick a81a2ff updating to scala 2.12.x; adding circe library for JSON
(use "git rebase --edit-todo" to view and edit)
You are currently rebasing branch 'master' on 'f3bd89d'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: services-core/src/main/java/edu/ncrn/cornell/service/CodebookService.scala
no changes added to commit (use "git add" and/or "git commit -a")
brandon@beb82dell0-DevContainer:~/workspace/ced2ar-core-services
$ git diff
diff --cc services-core/src/main/java/edu/ncrn/cornell/service/CodebookService.scala
index 02826ea,dbbdf12..0000000
--- a/services-core/src/main/java/edu/ncrn/cornell/service/CodebookService.scala
+++ b/services-core/src/main/java/edu/ncrn/cornell/service/CodebookService.scala
@@@ -126,41 -176,17 +176,51 @@@ class CodebookService
* @param handle
* @return
*/
++<<<<<<< HEAD
+ def getCodebookVariables(handle: String): Map[String, String] = {
+ //hashmap with varnames as keys and corresponding varlabls as values
+ val variables: mutable.Map[String, String] = mutable.Map()
+ //get all varname instances for a given codebook
+ val varnames: List[FieldInst] = fieldInstDao.findByRawDocIdAndFieldId(handle, "varname")
+ .asScala.toList
+ //for each varname find the labl and add to hashmap
+ for (varname <- varnames) {
+ val varnameId: Long = varname.getId
+ val varIndices: List[FieldIndice] = fieldIndiceDao.findById_FieldInstId(varnameId).asScala.toList
+ val varIndex: FieldIndice = varIndices.head
+ val varIndexValue: String = varIndex.getIndexValue
+ val lablMaps: List[Mapping] = mappingDao.findById_FieldId("varlabel").asScala.toList
+ val lablMap: Mapping = lablMaps.head
+ var lablXpath: String = lablMap.getXpath
+ lablXpath = lablXpath.replace("*", varIndexValue)
+ //find corresponding varlabl by canonical xpath
+ val varlabls: List[FieldInst] = fieldInstDao.findByRawDocIdAndCanonicalXpath(handle, lablXpath)
+ .asScala.toList
+ //check that xpath was mapped correctly
+ if (varlabls.size != 1) {
+ println("failed to properly map xpath from varname to varlabl: " + lablXpath)
+ }
+ else {
+ val varlabl: FieldInst = varlabls.head
+ //insert into hashmap
+ variables.put(varname.getValue, varlabl.getValue)
+ }
+ }
+ variables.toMap
+ }
++=======
+ def getCodebookVariables(handle: String): Map[String, (String, String)] =
+ getVarList(List(handle), 0)
+
+ def getCodebookVariables(handle: String, page: Int): Map[String, (String, String)] =
+ getVarList(List(handle), page)
++>>>>>>> a2fbc99... refactored details service return types, added pagination calls for var list services
- private def getVarList(handles: List[String]): Map[String, (String, String)] = {
+ private def getVarList(handles: List[String], pageNumber: Integer): Map[String, (String, String)] = {
val variables: mutable.Map[String, (String, String)] = mutable.Map()
- val varnames: List[FieldInst] = fieldInstDao.findByFieldId("varname").asScala.toList
+ val request: Pageable = new PageRequest(pageNumber, PAGE_SIZE, Sort.Direction.ASC, "value")
+ val varnamesPage: Page[FieldInst] = fieldInstDao.findByFieldIdAndRawDocIdIn("varname", handles.asJava, request)
+ val varnames: List[FieldInst] = varnamesPage.getContent.asScala.toList
//for each varname find the labl and add to hashmap
for (varname <- varnames) {
val handle: String = varname.getRawDocId
我可以尝试通过编辑并运行git rebase --continue
来对此进行修补,但始终,下一次提交将具有相同的问题,但通常会有更多的代码差异。
克隆后,我要做的只是git rebase -i --root
,将倒数第二次提交(关于许可)移至第二次提交,将pick
更改为fixup
,然后尝试进行重新设置。
答案 0 :(得分:2)
由于您使用的是交互式资源库,因此Git使用git cherry-pick
复制每个提交。
Cherry-pick实际上是一种合并(嗯,无论如何从Git 1.5.1开始)。但这是具有特殊合并基础的合并。普通合并如下图所示:
o--...--o--L <-- ours (HEAD)
/
...--o--B
\
o--...--o--R <-- theirs
这里,Git通过运行(实际上)git diff --find-renames <hash-of-B> <hash-of-L>
在分支中查找更改,并使用git diff --find-renames <hash-of-B> <hash-of-R>
在其分支中查找更改,并将其组合。
对于一个pick-pick,即使分支看起来很像,我们的目标是复制(一个特定提交的变化),所以Git确实看起来像这样:
o--B--R--...--o <-- theirs
/
...--o--o
\
o--...--o--L <-- ours (HEAD)
这里R
是要复制的提交,L
是我们当前的(即HEAD
)提交,而B
是比较特殊的合并基础。此时,Git对任何合并都执行相同的操作,将B
(他们的)和R
(我们的)两者中的L
(合并基础)进行比较,并合并更改。
如果存在合并冲突,则必须解决。完成此操作后,您将:
o--*--R--S--...--o <-- theirs
/
...--o--o
\
o--...--o--L--R' <-- ours (HEAD)
作为下一个选择:现在合并基础为R
,其提交为S
,而我们的提交为R'
。您刚刚解决的相同合并冲突很有可能再次发生。这就是您所看到的。
(对于这样的情况,git rerere
很有帮助。)