【发布时间】:2021-09-12 20:45:27
【问题描述】:
一些背景故事!
我一直在使用 git 为开源包做出贡献,我在这方面有点新手。我知道一些基本的东西。此外,我还读到如果发生合并冲突,我们可以遍历文件,标记可以帮助我们找到同一文件的两个版本中相互冲突的代码块。
最近,我第一次遇到合并冲突,它在 Jupyter 笔记本文件 (.ipynb) 上。但是,合并冲突的标记使 Jupyter 无法读取笔记本。所以,我尝试了 JSON 编辑器和 VS CODE 和 Notepad++。虽然我现在可以看到文件,但它真的很乱,因为它不仅包含 Jupyter notebook 的所有元数据,而且即使执行次数也显示冲突。另外,如果笔记本中有一个单元格输出的图形,它会被转换成很多字符,向下滚动浏览它们很头疼。
在 google 和 stackoverflow 上搜索并与项目所有者讨论问题后,我们决定采取另一种方法。但是,它不起作用。 (我在下面解释过,但首先我需要提供更多信息。请多多包涵)
根据提交的历史,我应该是在本地创建此类冲突的人,可能会更改 PARENT 分支上的同一文件,因为没有人在上游(在原始存储库中)更改它
因此,请让我先简要介绍一下我对文件所做的分支和一些更改。
- 分叉和克隆后,我创建了一个分支
branch-A - 我更改了笔记本“notebook-file”
- 我做了 Pull Request (PR)
- 我创建了A的一个子分支,我们称之为
sub-branch-of-A - 切换到子分支后,我更改了两个.py文件,然后也更改了
notebook-file - 将
sub-branch-of-A合并到branch-A
在我的branch-A 中,我做了:git push origin branch-A 但我得到了non-fast-forward 错误。这意味着发生了分歧。正确的?所以,我做了git pull origin branch-A 来解决它,但我遇到了notebook-file 的合并冲突。
替代解决方案
所以,有人告诉我可以将文件复制到本地 git 存储库之外的某个位置,然后执行 git checkout notebook-file 以在发生分歧的父节点中获取文件。正确的?然后,如果我这样做 git pull ... 应该没有问题(然后我可以包含该复制文件的更改)
但是...
我再次遇到合并冲突错误。我发疯了,尝试了几件事,但仍然没有。
我附上了下面的 git 日志。
我说的分支是Snippets_Tutorial,它的子分支是Snippets_Regime。如果我没记错的话,我使用git checkout -b Snippets_Regime Snippets_Tutorial 创建了那个子分支。如前所述,我切换到子分支Snippets_Regime 并对somefile.py 文件和notebook-file 进行了一些更改。然后,我将其合并到Snippets_Tutorial。
$ git log --all --graph --decorate --oneline
* 8d62ec9 (MERLIN_Tutorial) modify the code for comparing MERLIN3 (MATLAB) and MERLIN (Python) implementation
* 4952e92 (origin/MERLIN_Tutorial) Use MERLIN (of Table3) on Mars Science Labratory data to reproduce Fig. 17 of paper (top and botthm)
* 8d04aaa plot discords of NYC TAXI data that discovered by ONLY python or ONLT matlab
* 2bbb569 Revise DRAG, Implement MERLIN, and Try MERLIN on data
* 361824f correct the implementation of the algorithm to return correct NN index of the discords
* dd6eb87 Revise the implementation of DRAG algorithm provided in Table 1 and 2.
* 1adb0f6 Allow merge from main to my local branch
|\
* | 62e6b29 Add Tutorial for Matrix Profile XXI: MERLIN algorithm #Issue 417
| | * 81798ab (HEAD -> Snippets_Tutorial) copy back Snippet Tutorial notebook
| | * e680e0f allow git to track the file (?)
| | * eef7018 Copy back Snippet Tutorial notebook to the Snipperts_Tutorial branch
| | * 15ebf32 remove snippet tutorial local file from its developing branch tto allow merge from the main
| | * 06c05e3 merge updated files from origin to my branch (?)
| | |\
| | |/
| |/|
| * | 4c05d54 (upstream/main, origin/main, origin/HEAD, main) Fixed #414 Added fork syncing, checkbox fix to Contribute.ipynb
|/ /
| * be9169c resolve issues raised by flake8
| * c7a2654 (Snippets_Regime) update the notebook according to the updated version of snippet module
| * e4c0696 Change snippet_regime from list to numpy array
| * c6ab996 correct the block of code for plotting the snippets regimes
| * ed1b1a6 add the plot of snippets regime to check out the functionality of snippets_regime added to snippets modules
| * 52da7b2 remove blank line after docstring of a function
| * 6d599df use stumpy.mplstyle to refactor the rcparams
| * e968427 add the slices of indices for each snippet in the output
| * 910746e [WIP]: save temp changes
| * 911abaf [WIP] Revise the intro section and legend of figures
| * b47e727 Add textual context and Improve the flow and figures
| * b9ad95e Add the introduction part
|/
* 589630e Saved widget state in notebook
* 21abb19 Added empty array _get_array_ranges unit test
* 9f6c2cf Fixed #413 Edge Case in core._get_array_ranges
* db1c694 Updated STUMPY_EXCL_ZONE_DENOM test
* 7383cb7 Added gpu_stimp
* 1f1f426 Added stimped feature
* e87f9ad Fixed #411 Bad import of config settings
* 50a9089 Replaced mpl params with style file
* f80e6ce Fixed typo
* 000a0e6 Replaced nan_to_num in unit test
* c67fd56 Fixed #409 Added IPython to docs/requirements.txt; #409 (#410)
* 248ce34 Fixed typo in docstrings of subspace & _subspace (#406)
* c178889 Replaced nan_to_num with np.isnan
* 05cfc52 Fixed #237 Added STIMP (aka SKIMP) feature
* a59d57f Added bonus section on interpreting mp columns
* 9bf1944 Updated conda installation and environment
* 856dc75 Moved additional excl_zone parameter to config.py
* 48864d2 Added motif_idx with include/discords subspace example
* ebb3559 Added include/discords tutorial example to subspace
* 03bbdca Fixed grammar in contributor guide
* 3832b21 Fixed #385Clarifying the "Make your Changes" Section of Contributor Guide (#386)
| * 5f004a2 (origin/Snippets_Tutorial) [WIP] Revise the intro section and legend of figures
| * 0afad01 Add textual context and Improve the flow and figures
| * 9d0095a Add the introduction part
|/
| * 7a36675 (origin/Geometric_Chain, Geometric_Chain) Add chain analysis for respiration data and reproduce Table 2 of the paper
| * 01dc5d3 Correct/Update the markdowns and the result (adding discussion and figures)
| * e27b6b9 Correst docstrings of several functions
:
我附上了同样的东西,但以图像格式,因为我需要突出显示两个提交:
图片底部突出显示的提交是我可以在 fork 中看到的提交。
另一个突出显示的提交是当我认为我可以通过 git merge main <branch> 解决它时,而我在 <branch>。蓝色曲线包围的部分是事物合并的地方,不知道这里发生了什么(我的意思是,我不完全记得我发疯时使用的确切 git 命令)
如果我缺少某些东西,有人可以帮助我/指导我吗?
【问题讨论】:
标签: git jupyter-notebook git-pull git-log git-merge-conflict