denolehov / obsidian-git

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

Need some help: can't sync/push to remote • "fatal: bad object refs/heads" and "conflicting files" #606

Closed ricardonevesmusic closed 9 months ago

ricardonevesmusic commented 9 months ago
I'll try to explain my problem/issue, as best as possible.

(it might be more than just one problem/situation, as this thing already scaled up from when I first saw it/witnessed it, in the afternoon)

Describe the bug

Cannot sync/push to remote.

Several errors/issues (3 in total for now: as of 5:53 PM GMT+1/UTC+1 • September 22, 2023).

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

Obsidian console:

git obsidian error: Pull failed (merge): CONFLICTS: .obsidian/workspace-mobile.json:content

git obsidian error: Cannot push. You have conflicts in 1 file

git obsidian error: Did not commit, because you have conflicts in 1 file. Please resolve them and commit per command.

❌ Uncaught TypeError: Cannot read properties of null (reading 'frontmatter') at e.onFileOpen (app.js:1:2483715) at e.tryTrigger (app.js:1:700077) at e.trigger (app.js:1:700010) at t.trigger (app.js:1:2024836) at t.activeLeafEvents (app.js:1:2010986) at l (app.js:1:252040) at c (app.js:1:252156)

Full log: obsidian.md-1695399047348.log Additional screenshots: image 1image 2 Conflicting file screenshots:: image 1image 2


First sign/warning/notification of the problem/issue: • fatal: bad object refs/heads/~syncthing ~main.tmp error: https://github.com/username/Obsidian-Vault.git did not send all necessary objects

Second sign/warning/notification of the problem/issue:

conflict-files-obsidian-git (document inside Obsidian)

Conflicts

Please resolve them and commit them using the commands Obsidian Git: Commit all changes followed by Obsidian Git: Push (This file will automatically be deleted before commit) [[#Additional Instructions]] available below file list

  • Not a file: .obsidian/workspace-mobile.json

Additional Instructions

I strongly recommend to use "Source mode" for viewing the conflicted files. For simple conflicts, in each file listed above replace every occurrence of the following text blocks with the desired text.

<<<<<<< HEAD
    File changes in local repository
=======
    File changes in remote repository
>>>>>>> origin/main

Third sign/warning/notification of the problem/issue:

When I opened GitHub Desktop it showed this screenshot (it prompts to "Resolve conflicts before Merge").

It found one conflicting file: .obsidian/workspace-mobile.json (3 conflicts)

Last commit (vault backup: 2023-09-22 10:28:31 GMT+1/UTC+1): .obsidian/workspace-mobile.json

(strangely enough had 3 empty/blank/no changes made commits between 10:05:07 and 10:06:45 • GMT+1/UTC+1)

Steps to reproduce

Expected Behavior

Should be able to sync/push files to remote (it can't at the moment).

Addition context

This morning/afternoon, after creating new documents in Obsidian (mobile/android version), I've tried to sync some files to my repository with Obsidian Git (which always took too long to commit and push the files to remote • it took 5 minutes or more, always displaying the message "This takes longer: Getting Status").

Since then, I've been getting those messages/errors.

I've logged/gave auth access on Android via a 90 day GitHub classic token that only gives access to my repositories (don't know if more permissions were needed or if this doesn't apply to this situation at all).

Keep in mind that I'm pretty much a newbie and only started using Obsidian Git to sync to GitHub about 2-3 days ago (I've been using Syncthing/Synctrayzor to sync files between the PC/Android), so I don't have a lot of experience with Obsidian Git and GitHub.

So yeah, I hope you can help.

If you need more details, just let me know, I can send them to you privately, instead of sharing it over here for everyone to see.

Thank you.

Hope you can help.

(man, I really hope you can help me solve this problem, it really took me a long time to describe this for you -almost 2 hours- and I didn't worked on anything else since; not even changed/interacted with the GitHub Desktop message yet: other than just opening the conflicting file in Notepad++)

Operating system

Windows 10 Home x64 / Android 8.1.0

Installation Method

None/didn't install it recently (but if you need context: Community Plugins)

Plugin version

2.22.0

ricardonevesmusic commented 9 months ago

Fixed the problem.

Turns out I just needed to copy the content from one of my last file syncs of "workspace-mobile.json".

I renamed the "workspace-mobile.json" as "workspace-mobile.json.old" and then made a copy of that file and changed the original file back to "workspace-mobile.json" and pasted the content of one of the last syncs/changes.

When I open the console I no longer have any critical error (though some small/yellow sign issues that are available in the "Additional screenshots" part, still show: image 1image 2).

It's just that, but now everything seems to be back to normal (I'll monitor this situation a little bit more and then if it nothing changes in the next 24-48 hours, I'll update and close this).

Thank you.