Using Git to Configure Pandoc for Scrivomatic

As I set up Scrivomatic, it occurs to me that it might make sense to use git to clone the pandoc configuration files to my local pandoc directory. My reasoning is that any changes or additions made by @nontroppo will then be pushed to me. (That is how it is supposed to work, no?)

I am new to git so I could use some help. I assume the Terminal command must be git clone followed by a specification of the url of the repository on git

https://github.com/iandol/dotpandoc 

followed by the local target

~/.local/share/pandoc

or vise-versa, but the documentation of the clone command is a bit hard for this beginner to parse.

Hi, if you are not going to make any changes to the pandoc data files then yes, you can use something like:

➜ mkdir -p ~/Code
➜ cd ~/Code
➜ git clone https://github.com/iandol/dotpandoc

I prefer to keep all code I’ve downloaded in a specif folder; I then use a soft-link of that folder to the usual pandoc data dir location (use your user name in place of XYZ!):

➜ mkdir -p ~/.local/share/
➜ ln -s /Users/XYZ/Code/dotpandoc /Users/XYZ/.local/share/pandoc

Then when you want to fetch any changes, you simply cd to that folder (either the original or soft-link) and run a git pull to pull any changes from github to your local copy. You can also do this via a GUI, of which there are several, but github’s own client is good enough for most users: https://desktop.github.com

Note if you’ve made changes a git pull will fail, as a quick workaround you can stash these changes, then pull, then apply the changes back in place:

➜ git stash save
➜ git pull
➜ git stash apply

This is a simple solution to the problem of edited files; the better solution is below, but this steps you into more geeky territory, and you may not want to tread there…


BONUS (but more technical) SOLUTION:

The problem with a direct clone is that if you want to make changes to the files, then this can conflict with any git pull (though stash may help a bit). The “proper” solution to this is to use a fork. Forks can be edited independently, keeping their history while allowing the tracking of the parent. This parent is called upstream, and you can merge changes from upstream while keeping changes you make. Note this is more complex and you probably need to know a little bit about how to merge documents together if there is a conflict between the upstream and your version the GUI tools can help with this too, but it can be confusing for non-technical users.

First you make a user account on github, the on my dotpandoc page, press the fork button, then you clone your dotpandoc fork:

➜ cd ~/Code/
➜ git clone https://github.com/myuser/dotpandoc
➜ cd dotpandoc

You can check your remote links back to github:

➜ git remote -v

origin https://github.com/myuser/dotpandoc.git (fetch)
origin https://github.com/myuser/dotpandoc.git (push)

Add an upstream repository:

➜ git remote add upstream https://github.com/iandol/dotpandoc.git
➜ git remote -v

origin https://github.com/myuser/dotpandoc.git (fetch)
origin https://github.com/myuser/dotpandoc.git (push)
upstream https://github.com/iandol/dotpandoc.git (fetch)
upstream https://github.com/iandol/dotpandoc.git (push)

Fetch from the origin and upstream repositories:

➜ git fetch --all

Fetching origin
Fetching upstream
remote: Enumerating objects: 68, done.
remote: Counting objects: 100% (68/68), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 81 (delta 64), reused 67 (delta 64), pack-reused 13
Unpacking objects: 100% (81/81), 4.43 MiB | 679.00 KiB/s, done.

Merge changes from the upstream/master branch into your local master branch:

➜ git merge upstream/master master

Updating b825e4e26..b52ca1204
Updating files: 100% (406/406), done.
Fast-forward ...
2 Likes