obsidian-git icon indicating copy to clipboard operation
obsidian-git copied to clipboard

[Bug]: Mobile version not syncing

Open lnxfsf opened this issue 2 years ago • 18 comments

Describe the bug

On mobile version (android) it doesn't detect latest commits in git.

It shows that it fetched latest, and it's up to date. But it doesn't really sync at all.

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

There is conflict in sync that says

CheckoutConflictError: Your local changes to the following files would be overwritten by checkout: .obsidian/community-plugins.json, .obsidian/core-community-plugins.json, .obsidian/core-plugins.json

Steps to reproduce

Android doesn't sync latest data from git

Expected Behavior

No response

Addition context

No response

Operating system

Android

Installation Method

None

Plugin version

2.20.5

lnxfsf avatar Jul 02 '23 10:07 lnxfsf

Please describe what you are doing. Did you pull or a backup. Can you commit these files?

Vinzent03 avatar Jul 02 '23 10:07 Vinzent03

I can't pull It is not a backup. It can push, but not pull

lnxfsf avatar Jul 02 '23 11:07 lnxfsf

Because some commit you are trying to merge into your local branch has changed these files, you have to commit them for git to merge them properly. That's how git works.

Vinzent03 avatar Jul 02 '23 11:07 Vinzent03

no. but, I tried removing folder, following instructions you provided, to make new obsidian vault, install git plugin, insert my github username, and token. and then clone repo. which when I do, it clones everything as it should. But later, after that, if I make changes to notes on my PC, and push (and I see on website it is pushed and newer), then on mobile, it fetches, and says it's up-to-date. Even when trying to exit few times, reboot phone, same thing. It's like, it thinks, it pulled latest, and says it's up-to-date.

lnxfsf avatar Jul 02 '23 14:07 lnxfsf

Please open the source control view to see if you have those files changed, if so you have to first commit them as I already said.

Vinzent03 avatar Jul 02 '23 21:07 Vinzent03

Yes, changed, commited and uploaded. It sync on PC obsidian, but doesn't pull on android obsidian. From android obsidian it can push only.

lnxfsf avatar Jul 03 '23 11:07 lnxfsf

As a workaround I always end up with using git from termux.

I've simliar issues - obsidian-git is often even not able to perform a merge local changes when is behind & same time ahead remote (even when they're no conficts; yes I do have Pull changes before push enabled) :( Using git command line I just go with git pull, confirm merge title, and voilà

mwoz123 avatar Jul 18 '23 19:07 mwoz123

As a workaround I always end up with using git from termux.

I've simliar issues - obsidian-git is often even not able to perform a merge local changes when is behind & same time ahead remote (even when they're no conficts; yes I do have Pull changes before push enabled) :( Using git command line I just go with git pull, confirm merge title, and voilà

Yea, I ended up using termux to sync in background as obsidian sync is not good.

lnxfsf avatar Jul 19 '23 05:07 lnxfsf

Can termux be added as a mode to the plugin? "Use external git" or something, the JS-based one is terribly slow, doesn't work over SSH and makes using obsidian on mobile really unfriendly.

edit: termux exposes an intent for running commands, am decently sure it should be possible to use that.

Aonodensetsu avatar Jul 23 '23 15:07 Aonodensetsu

I'm also having this problem where the plugin says its working and gives me all thumbs up on a pull or push, but doesn't update; the same repo synced the repo and its respective Obsidian Git plugin to complete success and buttery smooth syncing across Win 10, Win 11, and 2 different Kubuntu machines.

I was amazed the plugin auto-synced to my phone anyway, so I'm not too put out. I'll use that Termux workaround for now.

retropele avatar Jul 30 '23 14:07 retropele

you can run this every hour via cronie in termux 0 * * * * /path/to/this/command <- this is a cron entry for "every hour"

cd /absolute/vault/dir
[ -z "$(find . -mmin -5)" ] && {
  [ -z "$(find . -mmin -70)" ] || {
    git add .
    git commit -m "vault backup"
    git push
  }
}

it checks if there are files updated in the last hour (70 min), but not in the last 5 minutes (to keep it from doing the push while editing), then pushes

regardless, i still insist on adding termux as an external git handler to obsidian-git

Aonodensetsu avatar Aug 06 '23 13:08 Aonodensetsu

I used this way. I'm using termux-job-scheduler , as there doesn't need to be a termux session active to perform cron jobs.

lnxfsf avatar Aug 06 '23 15:08 lnxfsf

yup, job scheduling is a good solution as well, and my script will work with it

Aonodensetsu avatar Aug 07 '23 10:08 Aonodensetsu

@Linuxiness

$ termux-job-scheduler -s ~/obsidian_notes.sh --persisted true --period-ms 900000 --job-id 1

`Cannot execute file: /data/data/com.termux/files/home/obsidian_notes.sh`

obsidian_notes.sh

#!/data/data/com.termux/files/usr/bin/bash
cd /storage/emulated/0/Documents/Notes
git pull --rebase
git add --all
git commit -m "$(date) : Samsung" 
git push origin main

Termux job scheduler doesn't seem to work for me. Using cron for now.

bearoxo avatar Aug 11 '23 06:08 bearoxo

@bearoxo is it executable? chmod +x /data/data/com.termux/files/home/obsidian_notes.sh?

mwoz123 avatar Aug 11 '23 07:08 mwoz123

@mwoz123 yesss.. that made it work. Thanks

bearoxo avatar Aug 12 '23 19:08 bearoxo

I think I have the same issue, where the android client notifies of "pull", "fetch", then "everything is up-to-date" even when it clearly isn't, remote has newer commits.... The source control view shows lists no changes, but If I do an 'empty' commit, it will revert everything on remote. Is the termux-job our current solution?

rzfzr avatar Oct 11 '23 13:10 rzfzr

It might be a placebo effect but I spot that synchronization works a little bit better if Source control view is not used on android.

@Vinzent03 is it possible that something in Source control view is doing some additional work that's delaying the sync?

mwoz123 avatar Oct 19 '23 06:10 mwoz123