Resolving sync conflicts in git folder.

How should I deal with the following files. I’ve already stopped syncthing, I won’t be using it in the forseable future for anything other than one-way sync from my phone camera to my desktop (usb cable replacement).

This is from a git repo that I work on between my desktop and laptop and then push to the server when the time is right. But somehow I keep ending up with these conflict files, and I don’t know enough about git’s underlying file structure to make an informed decision on what I should keep.

$ find ./ -name '*.sync-conflict-*'
./.git/COMMIT_EDITMSG.sync-conflict-20180728-155459-R24VAUQ
./.git/index.sync-conflict-20180701-193223-CF3AGJD
./.git/index.sync-conflict-20180207-220935-LEY5ZW7
./.git/index.sync-conflict-20171009-005327-LEY5ZW7
./.git/HEAD.sync-conflict-20180701-193124-CF3AGJD
./.git/index.sync-conflict-20180812-110741-R24VAUQ
./.git/COMMIT_EDITMSG.sync-conflict-20180728-164728-R24VAUQ
./.git/index.sync-conflict-20171009-005136-LEY5ZW7
./.git/COMMIT_EDITMSG.sync-conflict-20180701-192951-CF3AGJD
./.git/index.sync-conflict-20180207-220139-LEY5ZW7
./.git/index.sync-conflict-20171009-005311-LEY5ZW7
./.git/logs/HEAD.sync-conflict-20180728-124731-R24VAUQ
./.git/logs/refs/heads/multi_filter_dev.sync-conflict-20180701-193044-CF3AGJD
./.git/logs/refs/heads/vfd_dev.sync-conflict-20180701-193105-CF3AGJD
./.git/logs/HEAD.sync-conflict-20180701-193050-CF3AGJD
./.git/HEAD.sync-conflict-20180708-124119-CF3AGJD
./.git/index.sync-conflict-20171009-005221-LEY5ZW7
./.git/.addp-hunk-edit.diff.sync-conflict-20180204-001447-LEY5ZW7.swp
./.git/index.sync-conflict-20180207-220333-LEY5ZW7
./.git/index.sync-conflict-20171009-011325-LEY5ZW7
./.git/ORIG_HEAD.sync-conflict-20180701-192905-CF3AGJD
./.git/refs/heads/vfd_dev.sync-conflict-20180701-193027-CF3AGJD
./.git/refs/heads/multi_filter_dev.sync-conflict-20180701-193145-CF3AGJD
./.git/index.sync-conflict-20180207-220918-LEY5ZW7CF3AGJD.xml

How can i determine whether I should keep the conflict file or the existing file? Is there info somewhere on when they were last edited, and (possibly more importantly) which computer each was created from? The files i’ve tried to inspect are not human readable, so i’ll have to rely on other information to make an informed decision.

As a final note, this worked for a while, but changing computers, updating software, etc has left me in this mess, so be careful if you’re going to try syncing files that don’t have an obvious way to manually discern the differences to make an informed decision when conflicts arise.

Syncing git repos is a terrible idea for this exact reason. I would nuke the repo and clone from source.

2 Likes

Could you please explain why exactly “syncing git repos is a terrible idea”? Git repo is a folder with files as any other folder. Of course I have to be sure full synchronization is finished before working with repo at another computer. In such case I do not see reason why it should terrible idea.

It’s a terrible idea because as opposed to for example a folder with five Word documents in it, the files are not independent. If you have two sides making concurrent changes Syncthing will “merge” the two and the result is not something that is consistent in the Git world. The result is a corrupt repository.

Use Git as Git is intended: using fetch and push.

You might think that you can make sure only one side makes changes at a time. You are replying to a thread where that didn’t happen. If you got here by any search related to Syncthing resolving sync conflicts in a git folder, you are doing it wrong.

Do not use Syncthing to sync Git repositories.

Seriously.

Do not.

3 Likes

Thank you for reply. I got here when I was evaluating if syncthing is useful for me or not. I was looking for stability, errors etc. before testing it.

The only reason I asked was that this sentence: “Syncing git repos is a terrible idea” is to general and I feared there is some issue. It should have been written in this way: “Syncing git repos is a terrible idea if you have concurrent changes”

World is complicated, there are other applications that have complicated file/directory structures, not only git. And there are documents suitable for versioning, but pushing them somewhere is not needed etc. It would be too complicated to separate directories according if it is or is not git repository.

Separation isn’t needed, you can just ignore .git directories.

Not only git rely on specific structure and composition of files.

Still, this would not solve anything. E.g. I want to sync my whole working directory with many projects and documents to another computer and leave for a travel. I want to take the .git directories with me. The other possibility, to do git push and git pull for every git repository would be too complicated.

This is not a Syncthing limitation, it’s a property of Git repositories. You should use Git as Git is intended.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.