Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I have been working (alone) on an open-source project without using any sort of formal version control.

I recently started using Git and GitHub for this project and am wondering if it is possible for me to build a code/commit history based off of the archived, older versions of the code that I have.

Development thus far has been solely linear. It's progressed from version 0.1 through 0.9.6.3 without any branches.

I've looked through the Git User Manual and the closest thing I can think of would involve making labeled or named commits for each previous version.

What is the best way to handle this? Do I need to create a new repository and start pushing labeled commits into it, ending with the current version? Is it possible to change the dates of existing commits? Is there a more straightforward way?

I'm using Git on Windows XP (native, not Cygwin), but if it would be easier I can set it up on my Ubuntu box.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

The way you are doing the import is by setting up a git repo anywhere you want on the workstation where you have access to the sources, and point GIT_WORK_TREE to where you can load the successive version of your code base.

From there, you can git add and git commit the different versions of your code base, updating GIT_WORK_TREE to point to the right versions.

Use GIT_AUTHOR_DATE and GIT_AUTHOR_NAME for each import in order to set the right author's name and date. (See Environment Variables in Git)

share|improve this answer
    
Is that all I have to do? I think I'm missing something... My current git repo is set up in ~/workspace/NCC. The older versions are all in ~/workspace/nerocc/history. The first one is ~/workspace/nerocc/history/0.1_2009-08-28. In Git Bash, I ran the following commands: $ cd workspace/NCC $ GIT_AUTHOR_DATE=2009-08-28 $ GIT_WORK_TREE=~/workspace/nerocc/history/0.1_2009-08-28 $ git add ~/workspace/nerocc/history/0.1_2009-08-28 fatal: '<path>' is outside repository $ git commit That gives me a message about the untracked files in the current directory... –  corvec May 6 '11 at 14:47
    
@coverc: I am not sure a simple GIT_WORK_TREE=... is enough, depending on your shell. You should do an export GIT_WORK_TREE=... in order to make sure the value of that variable will be available for other processes (like the git command you are launching just after that). –  VonC May 6 '11 at 15:36
    
That's definitely what I was missing! I got it to work as follows, in git bash: $ cd workspace/NCC $ export GIT_AUTHOR_DATE $ export GIT_WORK_TREE $ GIT_WORK_TREE=~/workspace/nerocc/history/0.1_2009-08-28 $ GIT_AUTHOR_DATE=$(date -d 2009/08/28) $ git commit . $ git push Thanks! –  corvec May 6 '11 at 18:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.