denolehov / obsidian-git

Backup your Obsidian.md vault with git
MIT License
6.15k stars 252 forks source link

[Bug]: Pulled files end up as inverse staged changes #593

Open guycalledxan opened 10 months ago

guycalledxan commented 10 months ago

Describe the bug

Sometimes, when the plugin on my iPhone syncs and fetches latest changes that were last committed by my desktop, instead of the expected files being listed in "Recently Changed" they appear in Staged Changes. Files that were newly created in the desktop and that would be new on the phone are marked for delete. Files that previously existed are marked as Modified, but have no visible differences in the diff.

IMG_0242

If I un-stage the changes the status of the files (e.g. marked for delete) remains the same. When the changes are un-stages, if I click the revert icon on any type of change I get the confirmation prompt and after, the sync icon spins but the change does not revert when the icon stops.

If I commit the changes, the files erroneously marked for delete get deleted in my repository. If I revert the commit (on desktop), I can get my files back. But the next time I open the iPhone app, it does the same thing.

The only way I've found to get out of this state is to re-setup the vault on my phone again: Delete the vault from my phone's obsidian folder, Paste a copy of the desktop version back in; re-install the obsidian git plugin on mobile (it's in my .gitignore so it's one of the few things that doesn't get pasted in from the desktop version).

Relevant errors (if available) from notifications or console (CTRL+SHIFT+I)

No response

Steps to reproduce

I haven't really worked this out yet. It seems to happen after about a week after each time I re-setup the vault.

On this latest occasion:

I opened the mobile app. The mobile app loaded and created a daily note. The desktop app had also created the daily note, where I had added content and which had been pushed. The mobile app is set to sync on load. The daily note had a conflict. I reverted the daily note on the mobile app. This appeared to work. I did not commit from the mobile app. Obsidian git decided to sync again (I'm not sure what the trigger was). The other changes I had expected to arrive but which hadn't after the conflict notification now appeared, but as staged changes, instead of "Recently Pulled/Changed" (I forget the name and I can't see it at the moment). What should have been newly pulled files were marked for delete.

I don't remember whether on other occasions there was also a conflict before getting into this state. I think on at least one other occasion there was. I've had the problem with the daily note conflict before (which is a setup error on my part that I'm going to change make a second attempt to change, having just discovered my first attempt didn't work).

I don't know what other log/error data I could get that could help you out. Let me know.

Expected Behavior

When syncing, the files (especially the new files) end up on the phone, in the repository and are not marked for delete.

Addition context

I have this in 2.22.0, but I also had it in at least the previous version. If it's not somehow triggered by reverting a file with a conflict then it seems to happen after I've re-setup the vault on the phone. After about a week of use, I get the issue. This is my fourth time. I'm not sure how many versions that roughly 4 week time period covers.

Each time I first re-setup the vault, it works smoothly for a day or two. Then I start to get the "taking longer than expected" error/warning popup on every sync. This pops up on every sync, including ones where the files end up in staged changes in an inverted state.

Operating system

iOS

Installation Method

None

Plugin version

2.22.0

guycalledxan commented 10 months ago

Note that the daily note at the top of the picture was the daily note created on desktop, yesterday. It's not the note I had to revert, today.

The .json files are from having recently installed a new plugin (excallidraw) on desktop. I haven't .gitignore(d) .json by file type, but I have selectively ignored a lot of .folders and plugin folders. I haven't added the excalidraw folder (yet). I tend to ignore/sync plugins based on whether I want unique setups for mobile and desktop (and/or my two PCs).

In case it's of interest: I also have separate .obsidian and .obsidian-mobile folders. The .obsidian-mobile folder is not in my .gitignore but the desktop app should never touch that. The .obsidian folder is in my .gitignore.

I'm using Obsidian git to sync between three devices; iPhone, desktop and laptop. However, I rarely use the laptop and it hasn't pulled/pushed for around a week prior to this issue. I don't use any other sync in parallel to Obsidian git so there shouldn't be any of those kinds of two-sync-systems conflicts (I do copy the whole vault to a backup folder every now and again, but I haven't "restored" it on desktop a long while. When I re-setup the iPhone, I use the latest desktop folder, not an older backup).

TeemuSailynoja commented 4 months ago

This started happening to me after I added .obsidian to the repository. I then tried removing some specific files inside the .obsidian folder, but couldn't pinpoint what was causing this behaviour. I just removed the folder again and cloned the vault again onto my phone. All seems good for now, but I'll report back if the issue reoccurs.

TeemuSailynoja commented 4 months ago

It's happening again on what feels like an increasing frequency. I'm now trying to always close all notes and the app fully on one device, before opening it on another. Perhaps this is some kind of cache issue?

guycalledxan commented 4 months ago

Yeah, it was getting worse and worse for me too. At first I tried to avoid conflicts as much as possible; making sure to turn off opening daily note by default, for example. But eventually it was happening even when I couldn't find any reason for the supposed conflicts. In one case it seemed like the conflict was bogus. I ended up having to give up and turned the plugin off.

I had .obsidian and .obsidian_mobile in my repository and .gitignore to solve some other problems. I hadn't thought to try and remove stuff from those. So thanks for that new info. If I get some time at some point, I could try to start with a clean vault/repository. For now, months later, I'm too invested in the vault setup I have.

If this issue gets resolved and/or the plugin gains the ability to sensibly resolve conflicts and merge files then I'd love to come back to it.

gregorriegler commented 1 month ago

Running into the same issue. Makes this plugin unusable sadly