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.
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– corvec2011年05月06日 14:47:36 +00:00Commented 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 anexport GIT_WORK_TREE=...
in order to make sure the value of that variable will be available for other processes (like thegit
command you are launching just after that).VonC– VonC2011年05月06日 15:36:14 +00:00Commented 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– corvec2011年05月06日 18:36:10 +00:00Commented May 6, 2011 at 18:36