darkred darkred - 2 months ago 6x
Git Question

How to manage my greasemonkey userscripts using Git (in order to have them hosted in GitHub)

I'd like to use Git in order to facilitate the development of my userscripts (21). Also, I'd like to have them hosted in GitHub too. (using Greasemonkey with Firefox in windows 10).

So, my question is: what is the suggested way to manage my userscripts using Git, in order to also have them hosted in GitHub?

  • keep a separate folder (e.g.
    which will be my repo folder) containing copies of my userscripts files,

    i.e. each time I change one of my userscript files (located in

    I'll have to manually copy it from

  • have all my user userscripts in the same separate folder (my repo folder),

    and link them to the
    folder (using mklink -symbolic links- in a .bat file), as I've read in this answer

  • create just one repository containing my

    , apart from my 21 userscripts, I've got many other scripts installed, which I'll have to include in my

  • or is there any better way that I miss?

I've noticed the repos of two authors of many userscripts: @Mottie and @jerone
who have their many userscripts hosted in GitHub,
yet they follow different approaches:

Mottie's userscripts are all located in the root folder of the repo (just the .js files, there are no subfolders), (screenshot)

while jerone's userscripts are located each in its own subfolder in the repo (screenshot).

My guess is that Mottie has all his userscripts in the same separate folder (which is the repo), and has them linked to the

while jerone either just keeps a separate folder as a repo, with copies of his scripts,

or has his repo containing the

(but, jerone's .gitignore doesn't contain entries for those files in gm_folder that should be ignored, such as
and such. So, I'm not sure if that's the case)


I (the user above referred as @jerone) actually have two folders that I keep in sync: GreaseMonkey gm_scripts folder and checked-out repo folder on a different location.

The current folder structure on GitHub is there because I wanted to backup my scripts, just before Userscripts.org when offline. So I just copy-pasted my scripts (with folders) from the gm_scripts folder. Also because I've used some @requires before, keeping them in their corresponding folder.

I've not linked my gm_scripts folder to git because of using git branches for each userscript. The hassle of rebasing branches with the latest master is one reason. Another reason is that you can't work on two feature branches at the same time.

When working on a fix or new feature, I'm of-course working in the gm_scripts folder. When I'm happy with the live userscript changes, I use WinMerge to sync the changes to my checkout repo folder before committing the changes.

The .gitnore file is there, because I used Visual Studio to update the script, but I have changed to Atom long time ago.