[Feature]: Force pull / reset --hard HEAD
Would be super helpful to have the options to do a git pull --force that way when my phone and PC get out of sync I could easily fix things on my PC and get my phone back in sync without me having to remove the whole vault from my phone and cloning it again.
Seems like some others are also looking for this feature:
https://github.com/denolehov/obsidian-git/discussions/616
Update: as @Vinzent03 mentioned it should not be git pull --force instead it should probably do:
git fetch
git reset --hard HEAD
I don't think git pull --force is what you all are really searching for. As described in this article, I think you want a command which resets the working directly and then pulls.
same problem here..
I actually see now that the command "CAUTION: Discard all changes" already exists. After calling that command, the pull command should work.
@Vinzent03 I don't think ignoring the changes would help if the conflicting changes are already committed.
Having a hard reset option would be a great feature.
What exactly do you mean with the conflicting changes are already committed. Doesn't this mean the merge commit is already done and the pull therefore ended successfully. I don't see the difference between "hard reset" and the provided command.
@Vinzent03 thanks for responding. Here is what happens:
- Device 1 makes some changes and commits.
- Device 1 pushes the changes to remote.
- Device 2 makes some changes and commits.
- Device 2 tries to
pullthe changes before being able topushit's commit. - Device 2 Fails to
pullsince it already has conflicting changes in the commit. - Since there is no option to resolve the conflicts, the user is forced to delete the entire Vault in Device 2 and download the Vault from remote again.
How does a hard reset help? by doing a "hard reset" Device 2 will ignore it's committed changes and overrides everything with the remote's changes.
Hope it's clear.
This is extremely annoying. It would be great if you could add the hard reset/
@mubanga90 how do you fix this currently. Recreating the repo also deletes my settings.
@mgrottenthaler I've gotten a lot better at always syncing and closing obsidian when switching. When I do forget CAUTION: Discard all changes as @Vinzent03 pointed out works most of the time.
When it doesn't I don't recreate the repo:
- I delete vault (you will loose all changes on that device)
- Recreate the vault
- Add Obsidian Git
- Fill in my credentials
- Clone the Repo
- All other plugins and settings should then be back
But like I said I only had to that once or twice in the past months
After reading this, I suspect that it would also prevent to get into this situation if there was a good working way to merge changes from both sides. I made a custom 'sync' command with the extension 'better command palette' which aims at that to some extent (doing pull, commit, push), but of course I am also running into conflicts frequently on mobile. Maybe using merge via #572 would solve a lot of that?
One workaround: https://github.com/Vinzent03/obsidian-git/issues/340#issuecomment-1435836523