Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Force pull / reset --hard HEAD #702

Open
mubanga90 opened this issue Mar 1, 2024 · 10 comments
Open

[Feature]: Force pull / reset --hard HEAD #702

mubanga90 opened this issue Mar 1, 2024 · 10 comments
Labels
enhancement New feature or request

Comments

@mubanga90
Copy link

mubanga90 commented Mar 1, 2024

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:

#616

Update: as @Vinzent03 mentioned it should not be git pull --force instead it should probably do:

git fetch
git reset --hard HEAD
@mubanga90 mubanga90 changed the title [Feature:] Force pull [Feature]: Force pull Mar 1, 2024
@Vinzent03
Copy link
Owner

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.

@Vinzent03 Vinzent03 added the enhancement New feature or request label Mar 4, 2024
@slnw
Copy link

slnw commented Mar 7, 2024

same problem here..

@mubanga90 mubanga90 changed the title [Feature]: Force pull [Feature]: Force pull / reset --hard HEAD Mar 7, 2024
@Vinzent03
Copy link
Owner

I actually see now that the command "CAUTION: Discard all changes" already exists. After calling that command, the pull command should work.

@KhudaDad414
Copy link

@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.

@Vinzent03
Copy link
Owner

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.

@KhudaDad414
Copy link

KhudaDad414 commented May 15, 2024

@Vinzent03 thanks for responding.
Here is what happens:

  1. Device 1 makes some changes and commits.
  2. Device 1 pushes the changes to remote.
  3. Device 2 makes some changes and commits.
  4. Device 2 tries to pull the changes before being able to push it's commit.
  5. Device 2 Fails to pull since it already has conflicting changes in the commit.
  6. 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.

@mgrottenthaler
Copy link

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.

@bitfactory-douwe-devries

@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

@mmoole
Copy link

mmoole commented Jun 1, 2024

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?

@wangyandongnx
Copy link

One workaround: #340 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

8 participants