Marchie
Recently I decided to start a blog based on hugo and archie theme. There I mentioned that I liked the Idea of versioning the whole website and it’s contents using git. But I totally messed up the repo by trying to clone the theme’s repo to my own repo and apply changes locally. I expected the whole theme files, including changed ones, would then be pushed to my own repo. Turns out: nope. Next I tried to change the remotes, turns out that was also not the right way to do it.
Woah, that sounds stupid, how did you moron fix it?
Good question! The solution was simple, using a submodule, but it took me a while to figure it out. I created another empty folder on my local machine and git clone
’d the theme’s repo into it.
Afterwards I removed the original remote origin url and replaced it by my own github repo I created in advance:
git remote set-url origin https://github.com/wortkrieg/<private git name>.git
Checking back using git remote -v
told me: it worked! Yay! I can now
git commit -a
git push
my changes to my own repo.
Okay, but how did you bring this separate repo to your weblog’s repo?
That was also easy. cd
to the /themes/ folder of hugo and run
git submodule add https://github.com/wortkrieg/<private git name>.git
git submodule update <private git name>
Coolio, but how do you handle changes within the submodule?
When I now apply changes to the theme in my theme’s repo, I simply git commit
and git push
them. After that, I cd
into the /themes/
folder of this weblog’s repo and run
git pull
That’s all. That did the trick. I’m slowly starting to get this whole git thingy.
some may ask: ‘why didn’t you just create a fork using the big fat button within github?’ There are two reasons. First, github forks are always public and I hate putting everything in public. Maybe I’ll make the repo public later when there are changes worth sharing. Second, I’d be more dependent on github and I already think about moving to another (maybe self hosted) git. So I wanted to learn how to do it platform-independent.