So far, the mobile Git clients are a bit freewheeling, making odd changes and then committing them. When this happens, it’s a bit of a pain to fix, but it’s not impossible.
- Turn off automatic syncing in GitSync on phones
- Find the last good commit hash in
git logor on Forgejo - Run
git reset --hard <commit-hash>- Confirm that the history looks good with
git log
- Confirm that the history looks good with
- Force push with
git push origin +main- This is preferable to
git push -fbecause it only forces a push on the specified branch. If only one branch has an upstream tracking branch, the result is identical. If multiple branches have upstream tracking branches, only the specified one will force push. In GitSync on phones:
- This is preferable to
- Switch to “Client mode” in the dropdown under the recent commits
- Fetch origin to get the newly clean origin on the phone In PuppyGit on phones:
- Tap the branch name on the repo
- Tap-and-hold the remote branch (
origin/main) - Select reset and then choose “Hard”
- This takes about 30-45 seconds to complete and will show a toast at the bottom when finished In GitSync on phones:
- Confirm clean history
- This means that none of the commits will have colored backgrounds. (Blue background means local commit that has not been pushed; orange background means remote commit that is not in local branch)
- Switch back to sync mode
- Re-enable automatic syncing
Since desktop Obsidian only syncs while the app is open, only desktops that have had Obsidian opened since the problem commits were pushed need to be fixed. These are relatively easy to fix.
After the correct commits are on the remote:
git fetchto get the good remote branchgit reset --hard origin/mainwith the localmainbranch checked out to make it mirror the remotemain