# Obsidian-git users : How to put the ".git" folder outside of my vault (to avoid sync issues with iCloud)?

**URL:** <https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968>\
**Category:** Help\
**Created:** [June 16, 2025, 11:46am UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968 "2025-06-16T11:46:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 11:46am UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/1 "2025-06-16T11:46:27Z")

</div>

Hi,

My desktop vault (Windows 11) is synced to my Android phone with Syncthing, and to my iPad with iCloud.

I have set `isDesktopOnly` to true in obsidian-git settings. The `.git` folder is excluded from Syncthing.

Now, for security, I would like to put the `.git` folder outside of my vault, somewhere on my computer (like `C:/user/documents`), so that iCloud does not mess with it (so far, a year without any issues, but I’d like to avoid possible issues in the future).

Is such thing possible ?

I’m confused as to which setting I should use (Custom base path ? Custom Git directory path ? Can we use a full path like C:/user/documents/ ?)

Thank you very much.

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 12:28pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/2 "2025-06-16T12:28:21Z")

</div>

Git expects that hidden .git folder to be in the top directory of whatever you are putting under source control i.e. your vault. It’s not easy, as far as I am aware, to move it anywhere else that obsidian git will find it. For a normal git repository it can be put anywhere, as long as the GIT\_DIR environment variable is set. But that’s not an obsidian git thing. I’ve had .git directories in vaults before, but i don’t use obsidian git. I’ve then synced those with dropbox without issues. However that .git directory can get pretty large when lots of changes are made since all the versions of the files are hidden away in there. Since dropbox already does a form of version management, i decided to just delete the .git directory. I found obsidian git to be more trouble than it was worth. But that was two years ago, so it may have improved.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 3:58pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/3 "2025-06-16T15:58:38Z")

</div>

Thanks.

I understand, but then what are these “Custom Git directory path (Instead of ‘.git’)”, “Custom base path (Git repository path)” settings in obsidian-git ?

Also, I heard about moving the `.git` folder elswhere, and putting a `.git` **file** instead with the path of the moved `.git` folder inside.

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 4:18pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/4 "2025-06-16T16:18:06Z")

</div>

Don’t know. But Git requires a whole directory called “.git” and will place quite a few things in there to manage a repository. Not heard of the file with the path to the real thing, but it might be worth trying. I would experiment. If it works, when you type “git status” on the command line anywhere in the vault, it should show you a valid status if it can find the “.git” directory.

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 4:48pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/5 "2025-06-16T16:48:14Z")

</div>

OK. To try and help here i’ve created a test vault and installed the obsidian-git plugin. When I change the welcome note to add a new line and then run “git status” i get this:

carolinemathieson@MacBookPro Test % git status  
On branch main

No commits yet

Untracked files:  
(use “git add …” to include in what will be committed)  
.DS\_Store  
.obsidian/  
Welcome.md

nothing added to commit but untracked files present (use “git add” to track)

Which is what i would expect to see.

Then i closed down obsidian.

When i moved the “.git” directory onto my desktop and created a file called".git" with the path to that directory on the desktop, Obsidian then complained about there not being a valid repository.

This is without changing any of the settings in the plugin. I then changed the repository path in the setings and reloaded obsidian. But it didn’t like either the new path or file. Tried removing the file but leaving the directory in place and no difference.

My first thought is that this may not be possible. It may be the seting isnt quite right but someone who knows the git plugin would be able to give better advice.

I didn’t feel like trying any further experiments.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 4:58pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/6 "2025-06-16T16:58:21Z")

</div>

I’m sorry : it’s not the “PATH” only, it’s “gitdir: PATH” !

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 4:59pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/7 "2025-06-16T16:59:10Z")

</div>

When you initialise a git repository, it will try to manage everything in the main directory. You can tell it not to manage the hidden .obsidian directory using a .gitignore file for instance.

I use Git all the time but from the command line or from within an IDE. I’ve not tried using the plugin for a long time, so not sure what you mean by “gitdir: PATH”.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 5:02pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/8 "2025-06-16T17:02:15Z")

</div>

I meant, this is what you have to put in the `.git` file ! Not just `PATH` of the `.git` folder you moved, but `gitdir: PATH` : it should work !

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:02pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/9 "2025-06-16T17:02:48Z")

</div>

I see. Have you tried it and did it work?

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:08pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/10 "2025-06-16T17:08:12Z")

</div>

Just tried that and Obsidian still wasn’t happy with it.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 5:10pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/11 "2025-06-16T17:10:08Z")

</div>

Yeah, trying right now to make it work, I get an invalid gitfile format error. Will update.

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:10pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/12 "2025-06-16T17:10:38Z")

</div>

I get the same and also the vault not initialised error.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 5:13pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/13 "2025-06-16T17:13:59Z")

</div>

Ok, I think I made it work.

First, I initialized the vault with the appropriate obsidian-git command.

Then I moved the `.git` folder outside and specified its path in a `.git` file with `gitdir: RELATIVE_PATH` inside (should work with an absolute path as well).

Make sure to write `gitdir` and not `gitir`, which is a common mistake.

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:14pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/14 "2025-06-16T17:14:38Z")

</div>

where did you hear about the “.git” file trick because a quick  
google search isnt showing anything.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 5:20pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/15 "2025-06-16T17:20:24Z")

</div>

Someone on Reddit where I asked the same answered with this solution ! I’ll ask him how he discovered this.

Also, I just found that it is briefly mentioned in the git documentation here (in “Note” paragraph) : [Git - gitrepository-layout Documentation](https://git-scm.com/docs/gitrepository-layout).  
It’s not very explicit that we can move `.git` folder elsewhere with this `.git` file trick (for the use case discussed here I mean), but it seems to work…

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:23pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/16 "2025-06-16T17:23:04Z")

</div>

hmm,

**Note** : Also you can have a plain text file `.git` at the root of your working tree, containing `gitdir: <path>` to point at the real directory that has the repository. This mechanism is called a _gitfile_ and is usually managed via the `git submodule` and `git worktree` commands. It is often used for a working tree of a submodule checkout, to allow you in the containing superproject to `git checkout` a branch that does not have the submodule. The `checkout` has to remove the entire submodule working tree, without losing the submodule repository.

Maybe i have a setting in the plugin wrong? i only changed the path one. However deleting that and reloading stops obsidian from complaining about the gitfile but still complains about not finding a repositiry which is progress.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 5:29pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/17 "2025-06-16T17:29:35Z")

</div>

I made that experiment in a new vault with default obsidian-git settings.

First I used the “Git : Initialize a new repo” command. Then moved the `.git` folder elsewhere (just above in the tree hierarchy) and put a `.git` file in my vault with `gitdir : ../.gitREPO` (yes, I also renamed the `.git` folder as `.gitREPO` to check if we could change name).

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:36pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/18 "2025-06-16T17:36:07Z")

</div>

Sorry I could not help but i’ve learned something i didn’t know which might be useful another day.

---

<div class="post-metadata">

**Author:** ![JamesKF](https://forum.obsidian.md/user_avatar/forum.obsidian.md/jameskf/32/24490_2.png) [@JamesKF](https://forum.obsidian.md/u/JamesKF)\
**Post date:** [June 16, 2025, 5:39pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/19 "2025-06-16T17:39:59Z")

</div>

So you made it work too ? Nice, isn’t it ? Now I won’t be afraid that iCloud would mess with my `.git` folder !

Thanks for your presence which helped me set up & debugging this solution !

---

<div class="post-metadata">

**Author:** ![CarolineMathieson](https://forum.obsidian.md/user_avatar/forum.obsidian.md/carolinemathieson/32/35984_2.png) [@CarolineMathieson](https://forum.obsidian.md/u/CarolineMathieson)\
**Post date:** [June 16, 2025, 5:44pm UTC](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968/20 "2025-06-16T17:44:09Z")

</div>

I didnt get it work since obsidian didn’t like it. But as i have no intention of using the plugin, it does not matter too much. I only used it today to try and help.

[Next page](https://forum.obsidian.md/t/obsidian-git-users-how-to-put-the-git-folder-outside-of-my-vault-to-avoid-sync-issues-with-icloud/101968.md?page=2)
