1

I'm using this theme in my Hugo site: https://github.com/panr/hugo-theme-terminal

I've done a git clone for it and then setup submodules to point to the URL for it. That all works. However, I'm changing one of the files in the theme. Is there a way for me to still do submodules and point to the URL of this repo, BUT use the 1 modified file I have locallY?

user3498593
  • 113
  • 1
  • 1
  • 11

1 Answers1

1

It is best to fork the theme repository.

That way, you can:

Note: since the latest Git 2.25 release, it is easier to change the submodule url.
See "Git submodule url changed"

git submodule set-url [--] <path> <newurl>

As I explain in "How to make an existing submodule track a branch", you can make that submodule follow master with:

git submodule set-branch --branch master -- path

(using Git 2.22+, Q2 2019)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. If there are updates in the original, how can I make sure the one file I've modified doesn't get overwritten when syncing? – user3498593 Jan 19 '20 at 00:13
  • @user3498593 because, as describe in https://stackoverflow.com/questions/3903817/pull-new-updates-from-original-github-repository-into-forked-github-repository/3903835#3903835, you will be doing a rebase, which means you will replay your modification on top of the updated upstream Hugo them repo. – VonC Jan 19 '20 at 00:16
  • Think I got it. Right now there are no updates to the upstream repo, so I can't really test that. But I modified the file in my fork and pushed the change to it. So when there is a modification in the upstream repo I should be able to fetch upstream and then do a rebase to re-apply my changed file correct? – user3498593 Jan 19 '20 at 03:42
  • Yes, that is the idea. That will involve a force push (git push --force) to your fork, but since you are the only one working on it, that is OK. – VonC Jan 19 '20 at 04:09
  • I reference my fork URL in my .gitsubmodules file. The problem is that it appears to be using a non-master branch when referencing the submodule. I've been pushing my changes to the fork to master. Why is it referencing it by another branch the the original author used? – user3498593 Jan 19 '20 at 04:51
  • I added `branch = master` in my `.gitsubmodules` file and that seems to have corrected it. Is that the proper way to do it? – user3498593 Jan 19 '20 at 21:47
  • @user3498593 That should work, but I have edited the answer with the proper command to add a branch for a submodule to follow. – VonC Jan 19 '20 at 22:31