Setting up Obsidian Git on Windows for the tech uninitiated (with images)

Obsidian Git is an incredibly useful plugin, allowing users to back up their files periodically, in addition to having a changelog and version history.

Conventional methods of getting Obsidian Git up and running can prove to be challenging to those not familiar with command line.

Here is a guide, with images, to hopefully make that process a bit easier.

Sebsel posted a guide for macOS in the replies, which you can find here.


Obsidian Git on Mac?

So, about Git on Mac…

To my knowledge, macOS comes with Git preinstalled. I have installed a newer version through Homebrew, but I think the preinstalled version works just fine for most users who want to use the Obsidian Git plugin.

→ It turns out that macOS does not come with Git preinstalled. If you follow the steps I describe next, it might say something about installing the XCode Command Line Developer Tools. Git should be a part of this. You can also run xcode-select --install to install them. Other options are Homebrew, like I mentioned, or see this page for more installation options.

With that in mind, you can just follow the linked guide and skip the software installation step.

You can confirm this by opening the application called ‘Terminal’ and type the word git, followed by an enter. You will see something like the screenshot with the black background in the guide:

$ git
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

A few remarks:

  • you don’t actually need an account on Github to use Git. As the name suggests: Github is a hub for those who use Git. You can use other hubs (like Gitlab) or none at all. Github is a nice service though, I use it too.

  • If you want your Vault to be private, create a private repo on Github. If you don’t, everyone can read your Vault on the Github site.

  • Under the software installation step there is also a link to install Github desktop. This is a nice program for beginners with Git, and there is a Mac version too, so while you can skip the installation of Git itself, this Github Desktop program is still a nice one to have.

  • There is this step that says git config --global credential.helper wincred, and that will probaby not work for Mac. I myself use SSH keys, see this guide by Github, which can be a bit advanced, and uses the Terminal again.
    (There is also this guide specific to Github Desktop, but I think that will authenticate GhDesktop and not Git Obsidian.)

  • There is a step about viewing hidden files, but I don’t know if that’s really a prerequisite? On Mac, I always hide and show files by changing the true and false in the following Terminal command (which I have aliased):
    defaults write AppleShowAllFiles -bool true && killall Finder

  • The guide mentions trying to copy the .git folder into your Vault. This is a nice way to avoid the Terminal, but it makes me lose track of what’s going on. I would just use git init when I’m in the Vault in the terminal. (See below)

So, yes, I’m not smart enough to translate all this back to a non-terminal using guide, sorry about that. On Mac, for a new or existing Vault, I would do the following:

  1. Open the Terminal application. This is a preinstalled standard Mac app, which is probably easiest to find by using Spotlight and searching for Terminal. It looks like a black box with >_ on it.

  2. Type git and hit enter to make sure macOS indeed came with git. I would be surprised if it didn’t tho. See notes above.

  3. Go to your Vault in Finder and press Cmd+I on any of the files. This will give info about the file (hence the I) and will show ‘Where’ under ‘General’. For my Vault, it shows:
    If you copy that part with SSD, it will paste like this: /Users/seb/notes. That’s the location of you Vault you need.

  4. Go to the Terminal again and type cd /Users/seb/notes (with your own Vault path). You are now in your Vault in the Terminal. If you run the command ls you will see all your files and/or folders.

  5. Now that you’re in your Vault, you can type git init. This will create a Git Repository inside your Vault. (Technically, this means it did put a .git folder inside of your Vault. Obsidian ignores this folder. It does nothing to your actual files.)

From here, you can just use Github Desktop by pointing it to your Vault (‘add existing repository’). If you add the repository on Github too, you can coose ‘New’ and then leave all checkmarks unchecked under ‘Initialize this repository with’. It will then give you the following commands under ’ …or push an existing repository from the command line’:

git remote add origin [email protected]:sebsel/test.git
git branch -M main
git push -u origin main

Especially the first line is important, because the Git Obsidian plugin and the Github Desktop app can manage the rest. Also note that the example uses main as branch name, but depending on your version of Git this might still be master for you.

Again, if that does not work (of if it’s asking for login) you might want to look into this guide by Github for adding SSH keys.

Hope this helps, even though it contains a lot of Terminal commands!

Edit: turns out Git is not installed by default on macOS, so I changed the text to reflect that.


@Sebsel: many thanks for that, Seb, it is very useful indeed, no worries about using the terminal.

1 question I have, not specific to Mac: how private is one’s repository? What I mean is, can those who own/operate Github read your files?

tl;dr: Your files are private if you don’t push them and only keep them local (you will only get version history then, no sync). If you push your Vault to Github, Github can see your files. Also be sure to create a private repo, not a public one (these are free too nowadays).

That’s a good question!

If you do not create the repo on Github, not link it up, and do not push your repo to Github, then of course, there will be no copy of your files on Github. In that case, you will not be able to use Git to sync your Vault, but you can still get the benefits of a local repo: you will have version history.

Likewise, if you do push your Vault to Github, then those who run Github will be able to see it. Github is made for source code and a lot of companies trust their proprietary code too. It’s still a matter of trust though. Github is currently owned by Microsoft.

An important thing is also: in order to have your Vault private you have to create a PRIVATE repo on Github. If you do not specify this, your repo will be publicly visible, so everyone will see all your notes. I’ll edit this into my post too because it’s an important point for those who don’t wish to publish.

Like I said: there are other places to host your repo, it does not have to be Github. Alternatives are Gitlab, which has self-hostable options too. You can also just have your own VPS somewhere and push to a repo on that via SSH (this is a more advanced option, but I would say it’s the most private).

1 Like

@Klaas An easy way to verify your git repo is indeed properly set to private on Github is to create the repo with no notes in it and then try to visit that repo in a private browsing session (or in a completely separate browser) without logging in to Github. If you get an error then the repo is not visible unless you are logged in to your account.

It will also display “Private” next to the repo name in your list of repositories but this is a way to independently verify it.

1 Like

@davecan: thanks, that’s a good way to check.

Nevertheless, it may be private to the outside world, but how private is a private repo w.r.t. those running the show behind the scene?

Owner Microsoft is not exactly a privacy-oriented company, and is probably gleefully rubbing its virtual hands over all the new customer data that has coming and will be coming at its disposal. Does that include data from private repos?

Your concerns are valid, Klaas: these files are viewable by those who run Github and Microsoft is not known for being privacy-oriented. But, that’s not the whole story.

Github is made for software source code, and what you upload are raw text files. This is not nicely formatted data, with the same shape for every user performing the same action (like a ‘like’ on Facebook). They would need to spend man-hours on your specific files to extract something meaningful out of it. I doubt they will.

Second, because it’s for source code, they don’t expect you to put “data” into it. So that’s the second thing: I doubt they will analyze it at all.

And then the third thing: their business model is not extracting data out of users to sell ads to. Their business model is to host source code for others, who pay them for it. If they were to analyze that source code unwanted, they risk losing their customers. This is the third way in which they can’t be compared to Facebook.

But all that said: yes, it’s a company and you have to trust them. They have your data and can do stuff with it.


@Sebsel: thanks for that detailed explanation, Seb. The situation is now completely clear.

They would need to spend man-hours on your specific files to extract something meaningful out of it.

To be fair they certainly do perform bulk analysis of the code for a bunch of reasons. For one example, identifying insecure dependencies and then notifying project owners if they have a dependency with known security flaws and should upgrade to fix the problem. This is a great service they provide to the public and they can only do that through large-scale automated analysis of every project looking for those code dependencies.

That said, I agree with you, the risk of someone looking at your particular files in a targeted manner seems remote, though it isn’t zero risk.

But for some perspective, per Wikipedia they have 56 million users and 190 million repositories, only 28 million of which are public. Yours would be one of over 160 million private repos @Klaas. :slight_smile:

1 Like

@davecan: yes, I understand that. OTOH, processing big data volumes is not a big deal anymore these days. If you think that it is possible, for example, to monitor every single phone call and every internet move, which are volumes that are many orders of magnitude greater than Github repositories, then I am sure Microsoft could quite easily handle a mere 160 million repositories.