5

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.

asked May 3, 2011 at 15:16

1 Answer 1

5

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)

answered May 3, 2011 at 15:32
3
  • 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... Commented 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). Commented 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! Commented May 6, 2011 at 18:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.