How to Organize Git Repositories – Best Practices for Version Control

gitversion control

I'm struggling to phrase this question correctly, hence the poor title.

Basically I have a simple Chrome extension that I am developing for work. It is in use at the moment and as I am using it regularly I am constantly thinking of improvements or extra features it could have.

My file structure is like this (I'm on a mac)

~/Sites/Chrome_extensions/{my employers name}/CharCounter/

CharCounter/ contains all the files needed for the Chrome extension.

Whenever I am happy with a new version of my extension I pack it in Chrome and the resulting .crx file is called CharCounter_{version number}.crx

So for example, the most recent is called CharCounter_1.3.3.crx. However, the development folder currently always has the same name. If I want to roll back and continue developing a previous version I can't.

I have decided to start using git however I'm unsure how to tackle my version control.

Should I set up my git repository in

~/Sites/Chrome_extensions/{my employers name}

then when I decide I am making a big enough change to the extension to warrant a new version number I duplicate the CharCounter folder and add _{new version number} to it? Thereby having several CharCounter folders each with a different version number appending to them.

or should I set it up in

~Sites/Chrome_extensions/{my employers name}/CharCounter/

and never duplicate the CharCounter folder but just make a new commit every time I make a new version?

How do you tackle version control? Does using git do away with having to keep multiple versions (current and legacy) of your code in folders called folder_version_X.Y.Z or is that still a good idea?

Best Answer

The best solution would indeed be tags, perhaps something that might get what you want is to (partially) implement a workflow as illustrated here.

To make it easier to work with such a workflow a git extension has also been made which can be found here

This would allow you to:

  • Switch back to a previous version if that needs some bug fixing
  • Work on multiple new features at the same time (If this ever occurs)
  • Make sure you always have a fully working branch
Related Topic