2

Brainpick please :)

I've got a project which I'd like to move to a private GIT repository. I've started using Git for a couple of other projects, and it seems like a decent idea to try and solidify the current version control mess for this one.

At the moment, I've got several older archived versions (Just zipped up....) plus the current 'working' set.

I'd like to migrate this into a set of GIT branches (One for each 'gold' version so to speak) My plan looks a little like this at the moment:

  1. Extract the oldest version into a new directory, & create a GIT repository on this directory.
  2. Commit all changes and create a new branch.
  3. Delete the first set of files, and extract set #2.
  4. Commit these to master and create another branch.
  5. I should then end up at a stage where I've got several older branches and the current working master?

Is there a better way to be doing this? I know I'll basically end up with one branch per commit for the first few commits, but I can live with that.

leezer3
  • 280
  • 4
  • 10

2 Answers2

1

You don't need a branch for each import.

You can unzip each version into a new directory, but use only one git repo:

git init myGitRepo
cd myGitRepo

git --work-tree=/path/to/directory1 add .
git commit -m "rev1"
git tag -m "rev1"

git --work-tree=/path/to/directory2 add .
git commit -m "rev2"
git tag -m "rev2"

The --work-tree= allows git to consider different folder content as their working tree, which is useful to import several revisions from several different folders.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I would do the following:

  • create a brand new git project,
  • for each archive in the order
    • extract it in your project,
    • add everything,
    • commit
    • create a new tag (git tag your-tag-name) to tag the current archive's version

Which would create something like:

ghislain@debian: /tmp/gittags (master)
> git history 
* ca649d5  (HEAD, tag: v3, master) - third version (4 seconds ago)
* fbfb324  (tag: v2) - second version (21 seconds ago)
* 42f19f7  (tag: v1) - first version (38 seconds ago)
* 0ae4da8  - initial commit (65 seconds ago)

You can then list the existing tags of your repo with git tag:

ghislain@debian: /tmp/gittags (master)
> git tag
v1
v2
v3

And you can push your tags to a remote with:

git push --tags origin

Tags will behave globally like branches, except that they will be strongly linked to the commit where they've been created and if commit on top of it, the tag will not move.

For example, tags can also be checkouted (like branches).

padawin
  • 4,230
  • 15
  • 19
  • The tagging is good, especially that you provide more explanation, but you should recommend annotated tags as VonC does: http://stackoverflow.com/questions/4971746 – Phil Miller Jul 28 '14 at 14:40