JMRI Setup - Sharing Files with GitHub
Keywords: java model railroad JMRI install Dropbox

# JMRI Setup: Sharing Files with GitHub

GitHub is a free service that lets you share files between multiple computers across a network by storing a common copy in a Git repository. After you've signed up with GitHub and configured your local machine(s), you can configure JMRI to use it to share Rosters, layout configuration files and other information between multiple computers.

Note: If you're not familiar with Git and GitHub, you might be better off using Dropbox to share files between computers. Git and GitHub are a full-featured software version control system, which makes them more complex than the almost-automatic nature of Dropbox. Git and Github will let you control when changes are stored, have multiple versions on branches, and in general manage your JMRI configurations very closely; but if you just want share files, Dropbox may be easier.

Using Git has some advantages:

- In normal use, Git will keep the entire history of your files locally so that you can always back up to an earlier configuration.
- Git provides every powerful tools for managing updates when you're making changes on multiple computers, i.e. the main layout computer and some convenient laptoo.
- Git can be used with a sneaker-net connection by pushing/pulling from a copy of a repository on a USB stick.

The following approach should also work with other cloud-based file-synchronisation services such as Google Drive and OneDrive. However the Dropbox solution is well tested, having been used by a number of JMRI developers and users for quite some time.

### Step 1

To set up a shared User File Location on the web:

- Create a JMRI folder under Git control on the first computer. If you want to use GitHub, the steps are:
  - Create a GitHub account if you don't have one.
  - Create a new repository on GitHub using the "New" button on your Repositories pane.
  - Click the button named "(downarrow) Code" and copy the URL for your repository.
  - On your computer, in the directory you want to contain your JMRI files, check that repository out with (for example):

                    git clone https://github.com/myaccountname/JMRI.git

- If you have already created items (roster entries, panels etc.) go to Help‑>Locations and press Open User Files Location.
  This will open a window on your desktop showing a directory. Remember where that is, because you'll move items from there later.
- Still on the Help‑>Locations window, check to see if your Roster Location is different from the User Files Location. If so, click Open Roster Location to open a window on that location. You'll copy files from there later.
- Preferences‑>Roster‑>Roster‑>Roster Location‑>Reset. Do not enter a Roster Location. That way it will follow the setting for the User Files Location.
- Preferences‑>File Locations‑>User Files Location and set it to the JMRI folder you created in Dropbox.
- Restart JMRI and use Help ‑> Locations to make sure everything is changed correctly.
- If you have already created any files of the types listed at this link (see this page for help), move them from the old location to your new location. For example, your files in the User Files window we opened at the first step should be moved to the new User Files Location you just created.
- Use "git add", "git commit" to move all those files under Git's control.
- Finally, "git push" to push the contents back up to GitHub.

### Step 2-...

The only steps you need to do on subsequent computers are:

- "git clone" with the roster URL to make your initial download of the repository ("git pull" after that)
- Preferences ‑> Roster ‑> Roster ‑> Roster Location ‑> Reset. Do not enter a Roster Location. That way it will follow the User Files Location.
- Preferences ‑> Locations ‑> User Files Location and set it to the JMRI folder you created in Dropbox.

## Sneaker Net

First, copy the entire directory from one of your computers to the USB stick. This will be a master that you're moving around. (You can also directly 'git clone' onto the USB stick.)

Then, from your computer's JMRI preferences Git directory, you can bring the USB stick up to date with your directory with

                git commit -m"really lucid comment" .
                git push /path/to/USB/directory

Similarly, you can get the contents from the USB stick with

                git pull /path/to/USB/directory