Connect to external Code Repository and Link to Code Blocks Within

What I’m trying to do

I want to link to files in an external git repository within my vault. I use this vault both on PC (Linux) as well as my phone (Android). There are a number of specific things I would like to be able to do with this, which are covered below.

Assuming a copy of the repository is stored within the vault, keep all the files between them synced.

  • I could use an SMB share or similar to access the mounted filesystem, but this might be difficult to sync with my phone.
  • I might be able to use the obsidian-git plugin, but it appears to be tailored towards syncing the entire vault, and can only support one repository anyways.

Prevent modifying the repository’s filesystem from within obsidian, including modifying or adding new files/folders.

  • I haven’t experimented with how obsidian handles readonly files, but an SMB share could accomplish such a thing.

Link to specific blocks in the code, ideally without relying on obsidian’s block identifiers (since that would write to the repository’s files).

  • This one is tricky; I don’t know if it’s possible at all. My best idea is to give up on disallowing Obsidian markdown into the files, but somehow get all that markdown to be ignored when syncing. I have no idea how feasible that is though, especially considering major changes to a file (from outside the vault) that delete lines with markdown (within the vault).

If anyone has ideas on how this could be accomplished, or experience with anything similar, I would love to hear your thoughts.

I use the better code block plugin that lets me specify the filename and line number range which lets me see a specific part of the file without modifying it. My files are insde the vault and the whole vault sits inside a dropbox folder. But those files don’t have to be. It’s just convenient to have the code and the docs in the same place.

The only slight issue is that i can’t use it on an apple mobile device. But as i want to see the code on a large desktop window, that’s not a problem. Sometimes i sync the whole vault onto icloud and then sync any changes back again.

I use beyond compare to do that.

I don’t need to change the code files, just view them.