You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Obsidian with the Git plugin across multiple devices, I often run into synchronization conflicts. These aren't just from changing the .gitignore file—which I know isn't super common—but also from things like plugin data changing in the background or editing notes on different devices around the same time. It's a hassle because these conflicts can interrupt my workflow, and resolving them usually means I have to open up a terminal and run complex Git commands (e.g. hard reset, theirs flag, ours flag when merging), which isn't ideal.
I think a lot of these conflicts could be handled more smoothly if the plugin offered some built-in options to resolve them, like favoring "ours" (local) or "theirs" (remote) during merges, or providing ways to untrack files that are causing issues. It would be great if the plugin could help manage these situations without requiring users to dive into Git's command line, especially for those of us who aren't Git experts.
I'm sure some of the conflict handling tools for Git out there have other perspectives on solving this as well.
The main goal is to improve multi-device support by adding conflict handling options or a workflow UI or modal directly within the Obsidian Git plugin. This way, users wouldn't need to open a terminal to resolve conflicts—they could do it all from within Obsidian. The goal would be not to clutter the settings, so some of this could be under the Advanced section. I understand the Obsidian Git functions may work different in the background, so all of the implementations are just to show how it looks when doing them in a CLI.
Here are some ideas for features and settings that could help:
Flexible Conflict Resolution Settings:
Add a section in the plugin settings (maybe under "Advanced") dedicated to multi-device usage. This section could offer options for how the plugin handles conflicts when syncing between devices.
This could be a dropdown in the settings like "Multi-Device" or "Conflict Handling" or whatever is best for the UI
Command: Git: Untrack Ignored Files
Description: A command that untracks all files currently tracked by Git that match patterns in the .gitignore file. This helps prevent conflicts when syncing changes across devices, especially if the .gitignore has been updated on one device but not yet applied on others. This would emulate the same behavior talked about in the docs - Files in .gitignore aren't ignored.
Implementation:
The plugin could execute a command like: git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
I understand Obsidian Git may work in a specific way to get git working in the background, but this is the type of command that would be implemented. Since the exact command might differ across operating systems, the plugin should handle this internally, ensuring compatibility with Windows, macOS, and Linux.
Present the user with a confirmation dialog listing the files to be untracked, along with warnings about the impact.
Optionally, provide settings to choose whether to:
Automate this process during pulls.
Do it manually via the command palette.
Untrack files in bulk or one at a time.
Feature: Automatic Detection and Resolution of Conflicts Due to Ignored Files
Description: When the plugin detects conflicts caused by files that are now ignored (perhaps because the .gitignore changed on another device), it could prompt the user with options to resolve the conflict.
Implementation:
The plugin notices when a pull results in conflicts with ignored files.
A modal pops up, saying something like:
"We noticed that some tracked files are now in your .gitignore and are causing conflicts. Would you like to untrack these files to resolve the conflicts?"
Options in the modal could include:
Bulk Untrack Ignored Files: Untracks all the conflicting files at once.
Review Files: Allows the user to see the list of files and choose which ones to untrack.
Edit .gitignore: Opens the .gitignore file for editing, in case the user wants to adjust it.
Provide a brief explanation or bullet points about each option to help the user decide.
Commands for Merge Strategies with Inclusion/Exclusion Options:
Git: Use "Ours" Merge Strategy
Description: Resolves merge conflicts by favoring your local version of files (the "ours" strategy).
Before running, the plugin could offer options to:
Apply to all conflicts.
Apply only to specific files or folders (with inclusion/exclusion paths), which is helpful if you only want to favor local changes for certain plugins or directories. This could be implemented with a + button under Advanced Obsidian Git settings where you give the paths to them.
Provide a confirmation dialog explaining what will happen if need be.
Git: Use "Theirs" Merge Strategy
Description: Resolves merge conflicts by favoring the remote version of files (the "theirs" strategy).
Similar to the "ours" command, offer options to include or exclude certain files or folders. This could be implemented with a + button under Advanced Obsidian Git settings where you give the paths to them.
Provide a confirmation dialog explaining what will happen if need be.
Command: Git: Hard Reset to Remote Branch
Description: Resets your local branch to match the remote branch exactly, discarding all local changes—even those that aren't in conflict. This is different from the "ours/theirs" strategies because it replaces your entire local state with the remote state, not just resolving conflicts.
Before running, show a strong warning that this will discard all local changes, including any uncommitted work.
Require the user to confirm before proceeding.
Conflict Resolution Modal with Advanced Options:
Description: When conflicts occur, the plugin could present a modal dialog that provides various options for resolving them, similar to tools like GitHub Desktop.
Implementation:
The modal could include:
List of Conflicting Files: Shows which files are in conflict.
Options to Resolve Each Conflict:
Use Local Version ("Ours")
Use Remote Version ("Theirs")
Manual Merge: Open the file to manually resolve conflicts.
Bulk Actions:
Apply "ours" or "theirs" strategy to all conflicts.
Exclude or include certain files or folders in the bulk action.
Advanced Settings:
Allow users to set default behaviors for future conflicts.
Option to enable advanced conflict handling features.
Settings for Conflict Handling Behavior:
Description: Provide settings where users can configure how the plugin should handle conflicts by default.
Implementation:
Options could include:
Automatically Untrack Ignored Files: Enable or disable automatic untracking of ignored files during pulls.
Default Merge Strategy: Set a default preference for "ours" or "theirs" when conflicts occur.
Exclusions/Inclusions: Specify files or folders to always exclude or include when applying bulk conflict resolutions.
Enable Advanced Conflict Handling: A setting to show or hide advanced options and commands, preventing accidental use by less experienced users.
Platform Compatibility Considerations:
Description: Ensure that any command implementations are compatible across different operating systems (Windows, macOS, Linux) and their respective command-line interfaces.
Implementation:
Use platform-agnostic methods within the plugin when executing Git commands.
For commands that differ between OS's, the plugin should detect the OS and run the appropriate version.
For example, the command to untrack ignored files might differ:
On Windows Command Prompt: for /F %f in ('git ls-files -ci --exclude-standard') do git rm --cached "%f"
The plugin would handle these differences internally.
Why This Would Help:
Improves Multi-Device Support: By providing tools to handle conflicts that commonly occur when working across multiple devices, the plugin would make it much easier to keep notes in sync.
User-Friendly: Users wouldn't need to open a terminal or know complex Git commands to resolve conflicts—they could do it all within Obsidian.
Flexible and Customizable: Advanced users could configure settings to suit their workflow, while less experienced users could rely on sensible defaults and helpful prompts.
Final Thoughts:
I believe these features would make a significant difference for users who rely on Obsidian across multiple devices. By integrating conflict resolution tools directly into the plugin, it would simplify the merging process and reduce the friction caused by conflicts—especially for those of us who aren't Git wizards.
Let me know if this makes sense or if there's anything I can clarify!
I'd be happy to learn how to add to the plugin and contribute myself.
The text was updated successfully, but these errors were encountered:
cybersader
changed the title
[Feature Request] Conflict Handling Options/Commands to Help with Multi-Device Usage
[Feature Request] Conflict Handling to Help with Multi-Device Usage
Nov 4, 2024
Problem Statement:
When using Obsidian with the Git plugin across multiple devices, I often run into synchronization conflicts. These aren't just from changing the
.gitignore
file—which I know isn't super common—but also from things like plugin data changing in the background or editing notes on different devices around the same time. It's a hassle because these conflicts can interrupt my workflow, and resolving them usually means I have to open up a terminal and run complex Git commands (e.g. hard reset, theirs flag, ours flag when merging), which isn't ideal.I think a lot of these conflicts could be handled more smoothly if the plugin offered some built-in options to resolve them, like favoring "ours" (local) or "theirs" (remote) during merges, or providing ways to untrack files that are causing issues. It would be great if the plugin could help manage these situations without requiring users to dive into Git's command line, especially for those of us who aren't Git experts.
I'm sure some of the conflict handling tools for Git out there have other perspectives on solving this as well.
Related Issues and Obsidian Git docs:
git pull --force
from the mobile app? · Vinzent03/obsidian-git · Discussion #616.gitignore
theworkspace.json
file? · Vinzent03/obsidian-git · Discussion #709Proposed Solution:
The main goal is to improve multi-device support by adding conflict handling options or a workflow UI or modal directly within the Obsidian Git plugin. This way, users wouldn't need to open a terminal to resolve conflicts—they could do it all from within Obsidian. The goal would be not to clutter the settings, so some of this could be under the Advanced section. I understand the Obsidian Git functions may work different in the background, so all of the implementations are just to show how it looks when doing them in a CLI.
Here are some ideas for features and settings that could help:
Git: Untrack Ignored Files
.gitignore
file. This helps prevent conflicts when syncing changes across devices, especially if the.gitignore
has been updated on one device but not yet applied on others. This would emulate the same behavior talked about in the docs - Files in .gitignore aren't ignored.git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
git
working in the background, but this is the type of command that would be implemented. Since the exact command might differ across operating systems, the plugin should handle this internally, ensuring compatibility with Windows, macOS, and Linux..gitignore
changed on another device), it could prompt the user with options to resolve the conflict."We noticed that some tracked files are now in your
.gitignore
and are causing conflicts. Would you like to untrack these files to resolve the conflicts?".gitignore
: Opens the.gitignore
file for editing, in case the user wants to adjust it.Git: Use "Ours" Merge Strategy
git merge --strategy-option ours
+
button under Advanced Obsidian Git settings where you give the paths to them.Git: Use "Theirs" Merge Strategy
git merge --strategy-option theirs
+
button under Advanced Obsidian Git settings where you give the paths to them.Git: Hard Reset to Remote Branch
git fetch origin git reset --hard origin/$(git rev-parse --abbrev-ref HEAD)
git ls-files -ci --exclude-standard -z | xargs -0 git rm --cached
for /F %f in ('git ls-files -ci --exclude-standard') do git rm --cached "%f"
Why This Would Help:
Final Thoughts:
I believe these features would make a significant difference for users who rely on Obsidian across multiple devices. By integrating conflict resolution tools directly into the plugin, it would simplify the merging process and reduce the friction caused by conflicts—especially for those of us who aren't Git wizards.
Let me know if this makes sense or if there's anything I can clarify!
I'd be happy to learn how to add to the plugin and contribute myself.
The text was updated successfully, but these errors were encountered: