DEV Community

aurel kurtula
aurel kurtula

Posted on

Using SVN to manage your code snippets in GitHub!

I've been looking for the ability to do this since I learned Github, but I never found any solution, I didn't even think it was possible.

Every time I'm frustrated with my workflow I end up researching on the same topic and I finally found the solution

Problem: When starting work on a new project you want to be able to paste the same SASS directory to your project, you might have reusable components, fonts and so on. Having them in a directory in your machine is, meh. I find it annoying. Why use an extra GUI.

Desire: I always wanted GitHub to be the answer. But of course, as we normally use Git, it doesn't work, the workflow would be the same as the problem we are trying to solve (but with version control)

Solution: SVN commands.

I should know more about SVN before writing this post but I got what I wanted from it and so I am writing this more as to not forget the setup I've created and hopefully it might help some of you.

With SVN commands a Github repository is like a file storage site that I can import and export just the resources I want.

I made a private repository in Github and pushed some initial resources

The https could be:

I can delete the project from my computer but still import and export anything from that project with svn import and svn export

Go into the directory where the resource you want to import is located and run

svn import -m -F ""

There, a file located in your computer is pushed to the Github repository.

Exact same thing with exporting resources

svn export

Note the URL pattern: The cloning HTTPS address, followed by /trunk/ and the file or folder you want to export or import.

Use terminal/shell methods as shortcuts

I'm really happy with the above, I might read more into SVN but for now it does the job and my use is clear, to use for repositories where I don't really care about the commit logs and so forth, just a drop-box kind of functionality I can manage from my terminal.

I user oh-my-zsh framework to manage my zsh configuration. For any commands that will be repetitive, I always add a method in the zsh configuration:

    # file = $2
    # path = $1
    svn import -m -F $2 $1/trunk/$2

Now if I ever want to import any file/folder to any of my repositories I just run svnpush https//:github...reponame.git localFoder

    # file = $2
    # path = $1
    svn delete $1/trunk/$2 -m 'deleted $1'

The ability to delete resources from the repository is import, it's the only way to "modify" existing resources.

    # file = $2
    # path = $1
    svn export $1/trunk/$2

Finally exporting.


I'm so excited about this because honestly, I've tried so many things and they all seem to distract me.

This reminds me of my note taking method which I've used for years and still find it extremely simpler than everything else I have tried.

There might be drawbacks if you use this instead of git for your code, there definitely must be. I want to emphasise that this is just a container to dump resources into

Top comments (3)

sergioavaldez profile image

Did you try git submodule?, I think it could do the work.

aurelkurtula profile image
aurel kurtula

No, don't even know what that is.

Can you explain?


sergioavaldez profile image

As explained in this blog post

Submodules allow you to include or embed one or more repositories as a sub-folder inside another repository.

The article explains very well how to use submodules, maybe this can fit better your needs.