How to make Obsidian rename work with git?

Things I have tried

I’ve tried searching the forum for existing advice and looked at the documentation for the Obsidian git community plugin but can’t find any mention of this, apart from this request for git integration.

I’m aware that Obsidian sync is available but I’d prefer to use git if I can.

What I’m trying to do

I’d like to be able to use the Obsidian rename function, since it’s so helpful that it updates all links in other notes. The problem is that git sees this as a file deletion and a new file with the new name, not a rename of the existing file.

If I use git mv to rename the file from the command line, I can’t use Obsidian to update links. I could potentially git mv to rename the file, change the name back to the original in Obsidian, then use Obsidian to rename it back again and update links…but this isn’t a particularly smooth workflow!

Has anyone found a way to make this work for them?

I’m using Obsidian on mac and windows, and am planning to start using it on android and iOS as well.

Thanks ever so much.

I contacted the developer of the Obsidian git community plugin, who was amazing and replied really quickly. It turns out I just didn’t understand how to use git properly so I’m posting the answer in case anyone makes the same mistake.

I was running git status after renaming notes in Obsidian and getting concerned because it looks like git sees it as a file deletion and recreation. Turns out I should have had the confidence to run git add, which detects the rename. You can confirm this by running git status again afterwards.

git mv (which I’ve always used in the past) just renames and adds the file(s) to the staging area.

So I had no need to worry: git does work nicely with the Obsidian rename function. I just needed to use git add as normal to add the renamed files to the commit.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.