Sharing Files Across Repos on GitHub

Posted on
Mon Mar 06, 2017 5:04 pm
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Sharing Files Across Repos on GitHub

I have now moved the documentation for all my plugins to GitHub. While it's evolving, I'm making greater use of CSS. What I'm looking to do is to use one CSS file to support all my repositories. In fact, I'd like to be able to move several common elements to their own HTML files so that I only need to edit one file to make changes to common stuff. Apparently, this is easier said than done with GitHub. Has anyone figured out a way to share files across multiple repositories without getting into complicated stuff like submodules? Maybe it's just not possible. The closest thing I've been able to come up with is to put the CSS file in Dropbox, but that seems like bad form.

Much appreciated,
Dave

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Mar 06, 2017 8:32 pm
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

Back to answer my own question, although I'm not sure it's necessarily the best approach. Here's an example for the CSS file.

  • Create a new repo called "common".
  • Make the repo's pages public.
  • Copy the CSS file to the common repo.
  • Direct other repo's CSS calls to the common repo full URL

Code: Select all
 <link rel="stylesheet" type="text/css" href="https://username.github.io/common/filename.css">

I tested this with one of my plugins by changing the common CSS and it flowed through.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Mar 07, 2017 10:30 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sharing Files Across Repos on GitHub

While reading your first post, that's exactly what I thought would be a good first try. I'm not sure there's any other way to share files other than to use a separate repo.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 07, 2017 12:16 pm
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

jay (support) wrote:
While reading your first post, that's exactly what I thought would be a good first try. I'm not sure there's any other way to share files other than to use a separate repo.

Thanks Jay. It's apparently not something that people do very often, or I'm missing something. I came up with a lot of information about using submodules which was overkill for what I'm trying to do. So far, this setup is working well for me.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Fri Mar 10, 2017 3:16 pm
MartyS offline
Posts: 86
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: Sharing Files Across Repos on GitHub

DaveL17 wrote:
Code: Select all
 <link rel="stylesheet" type="text/css" href="https://username.github.io/common/filename.css">

Presuming that a URL to a mythical project might be
Code: Select all
https://username.github.io/project14/index.html
I have not tested it myself, but I would think that you could eliminate the "common" project if you don't have any other use for it by using a relative reference such as
Code: Select all
 <link rel="stylesheet" type="text/css" href="../project1/filename.css">
where "project1" is whichever project you plan to keep the real file. It's not any closer to a win-win but it eliminates having a project with just a few files that don't really make up a project by itself—or if GitHub were to charge by the number of repositories you have.

/Marty

Posted on
Sat Mar 11, 2017 5:40 am
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

Interesting. I hadn't thought of trying relative links. I have everything set up now for the common project approach and it's working well. Your idea is a good fall back if there's some kind of repo limit or fee-per-repo (like you suggested).

Still learning HTML5, but common HTML content is working pretty well too. For example, I have a file that contains information about reporting bugs and whatnot and then I include it as an object in my other pages.

Code: Select all
<object name="features_and_bugs" type="text/html" data="https://username.github.io/common/features_and_bugs.html" style="width: 100%; height: 280px;"></object>

I'd be interested if anyone has advice for better ways of embedding HTML in a page as this approach works to an extent but there are a few drawbacks. For one, the content is slightly narrower than the rest of the page. Also, the height parm is relative to the container and not to the content so if my object becomes larger than 280px (in this case) it sprouts a scroll bar--which is serviceable, but looks hideous.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Sat Mar 11, 2017 9:39 am
MartyS offline
Posts: 86
Joined: May 06, 2008
Location: Charlotte, North Carolina

Re: Sharing Files Across Repos on GitHub

Since I haven't used GitHub Pages myself, after reading about it it seems that they address what you need in their User pages. It's a place to have items published into https://username.github.io/. Then you can either use the relative URL idea I showed (../filename.css in the new way) or by full URL to https://yourname.github.io/filename.css, etc.

By using their User pages, you wouldn't have to remember which repository was your "base" for storing these common items.

/Marty

Posted on
Sat Mar 11, 2017 5:32 pm
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

Thanks for the tip. I've got it up and running and will look at it some more. It sounds like a cleaner approach.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Mar 13, 2017 7:36 pm
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

After working on this for a bit, I think it's a good approach, but there are caveats.

Pros:
  • Fully supports the "common files in one place" goal.
  • Easily maintained with an IDE like PyCharm. I can now maintain plugins, scripts and user pages all from one place.
  • Relative URLs work, but break local previews. This is overcome by using the full URL to the resource, instead.
Cons:
  • None that I can think of.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Mar 14, 2017 8:52 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sharing Files Across Repos on GitHub

I'm curious - how can you manage user pages from PyCharm if the user pages aren't actually part of the repo?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 14, 2017 9:16 am
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

jay (support) wrote:
I'm curious - how can you manage user pages from PyCharm if the user pages aren't actually part of the repo?

It was easy.

  • Go to GitHub and create a new repository named username.github.io (following these instructions provided by GitHub).
  • Once that's complete, open PyCharm and from the Welcome to PyCharm screen, select "Check Out From Version Control", and then "Git".
  • Checkout Git Repository URL "https://username.github.io".

Reference:
Code: Select all
<link rel="stylesheet" type="text/css" href="https://username.github.io/filename.css">
It worked slicker than you-know-what.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Mar 14, 2017 9:34 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sharing Files Across Repos on GitHub

Oh, sorry, I thought you meant that you could manage user files when you had a different repo opened. So, from your use case, there really isn't much of a practical difference between using user files (which is just a special repo) vs just another repo. Am I missing something?

BTW, I'm not dismissing user pages - they seem to be a great (and simple) way of publishing a website with an easy to remember URL pattern.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 14, 2017 10:42 am
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

jay (support) wrote:
Oh, sorry, I thought you meant that you could manage user files when you had a different repo opened. So, from your use case, there really isn't much of a practical difference between using user files (which is just a special repo) vs just another repo. Am I missing something?

BTW, I'm not dismissing user pages - they seem to be a great (and simple) way of publishing a website with an easy to remember URL pattern.


You're right, there's not a huge difference. At least not one that I have spotted yet. But one smaller benefit is that it allows for a clean, easy to remember vanity URL where I can point users to links to my contributions.

Hence, this work in progress: https://davel17.github.io/

:D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Tue Mar 14, 2017 11:45 am
jay (support) offline
Site Admin
User avatar
Posts: 18220
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Sharing Files Across Repos on GitHub

Ok, just wanted to make sure I wasn't missing something.

It is a great place for a website, and nice start on yours!

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Mar 14, 2017 12:52 pm
DaveL17 offline
User avatar
Posts: 6754
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Sharing Files Across Repos on GitHub

Thanks Jay. It's getting there. :D

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 4 guests