spine-generic / data-multi-subject

Multi-subject data for the Spine Generic project
Creative Commons Attribution 4.0 International
22 stars 15 forks source link

How to git rebase if there are conflicts with the metadata #42

Closed jcohenadad closed 4 years ago

jcohenadad commented 4 years ago

After merging #37, I wanted to update #40 with master. So I did the following:

git checkout master
git pull
git checkout jca/update-derivatives
git rebase master
detailed output ~~~ First, rewinding head to replay your work on top of it... git-annex: git status will show derivatives/labels/sub-fslAchieva01/anat/sub-fslAchieva01_T2star_rms_gmseg-manual.nii.gz to be modified, since content availability has changed and git-annex was unable to update the index. This is only a cosmetic problem affecting git status; git add, git commit, etc won't be affected. To fix the git status display, you can run: git update-index -q --refresh derivatives/labels/sub-fslAchieva01/anat/sub-fslAchieva01_T2star_rms_gmseg-manual.nii.gz git-annex: git status will show derivatives/labels/sub-tokyoIngenia03/anat/sub-tokyoIngenia03_T2star_rms_gmseg-manual.nii.gz to be modified, since content availability has changed and git-annex was unable to update the index. This is only a cosmetic problem affecting git status; git add, git commit, etc won't be affected. To fix the git status display, you can run: git update-index -q --refresh derivatives/labels/sub-tokyoIngenia03/anat/sub-tokyoIngenia03_T2star_rms_gmseg-manual.nii.gz Applying: Added derivatives for GM segmentation Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... error: Your local changes to the following files would be overwritten by merge: derivatives/labels/sub-fslAchieva01/anat/sub-fslAchieva01_T2star_rms_gmseg-manual.nii.gz derivatives/labels/sub-tokyoIngenia03/anat/sub-tokyoIngenia03_T2star_rms_gmseg-manual.nii.gz Please commit your changes or stash them before you merge. Aborting error: Failed to merge in the changes. Patch failed at 0001 Added derivatives for GM segmentation hint: Use 'git am --show-current-patch' to see the failed patch Resolve all conflicts manually, mark them as resolved with "git add/rm ", 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". ~~~

Given that there seem to be some conflicts with the metadata, I am not sure what is the best way to fix them.

jcohenadad commented 4 years ago

As indicated in the message, this is a cosmetic glitch, which is also discussed in our documentation.

So, I went ahead and ran:

git status | sed -n 's/modified://p' | xargs git update-index -q --refresh
git rebase --continue
But it seems the rebase doesn't want to continue... ~~~ Applying: Added derivatives for GM segmentation No changes - did you forget to use 'git add'? If there is nothing left to stage, chances are that something else already introduced the same changes; you might want to skip this patch. Resolve all conflicts manually, mark them as resolved with "git add/rm ", 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". ~~~
jcohenadad commented 4 years ago

Then I did the following (still no success):

julien-macbook:~/code/spine-generic/data-multi-subject $ git rebase --skip
Applying: Removed sub-sapienza01 (site name changed)
julien-macbook:~/code/spine-generic/data-multi-subject $ git rebase --continue
fatal: No rebase in progress?
jcohenadad commented 4 years ago

ah! but looking at the log, it seems like the rebase worked:

* 0e4ba12916fc722e7f8138ad25571356ac93e449 (HEAD -> jca/update-derivatives) Removed sub-sapienza01 (site name changed)
* 91bb13eb2ca179a61da539c59f5951e8cc6019f9 (origin/master, origin/HEAD, master) Update README.md
| * 34c6c70bc2e4c2a874c5f1da340188b0e8cd00c7 (origin/synced/jca/update-derivatives, origin/jca/update-derivatives, synced/jca/update-derivatives) Removed sub-sapienza01 (site name changed)
| * 3a107bc799d756c47a73560246987d4e879bcce2 Added derivatives for GM segmentation
|/  
| * d320819cfd1b9e50b1734163bf11a861d4722cbf (origin/synced/git-annex, origin/git-annex, git-annex) update
| * 957506b34a1cdd442b4213aa1f22882033b19859 update
| * c8beb602d2523561989ec6537133c20db410bb03 update
| * 2cd290bf030a254130704119bf2bd59ef326f333 update

then i pushed, and it fixed it (i hope i didn't break anything...):

 git push -f
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 16 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 501 bytes | 501.00 KiB/s, done.
Total 6 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To https://github.com/spine-generic/data-multi-subject.git
 + 34c6c70b...0e4ba129 jca/update-derivatives -> jca/update-derivatives (forced update)
kousu commented 4 years ago

In theory there's no way to cause conflicts in the metadata -- in the git-annex branch -- because it's careful about how it edits that to prevent conflicts. If conflicts do happen in that branch I don't know how to fix it; hopefully it never happens and if it does we can go in with a spanner.

This case was instead a problem with update-index, which it looks like you solved.