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 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.

1 Answer 1


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)

  • 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, 2011 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, 2011 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, 2011 at 18:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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