user2476789
user2476789

Reputation: 23

How do i clone an old commit into a new repo?

I used git to track changes in a project. The first couple of commits were all about setting up the environment and including a bunch of plugins to get a bare framework.

How do i start a new project starting from one of the old commits from my existing project?

Upvotes: 2

Views: 174

Answers (3)

VonC
VonC

Reputation: 1329072

Note that using a zip format can be problematic on very large repo, depending on the unzip software used (especially on Windows).
That is what git 2.6 (Q3/Q4 2005) addresses:

See commit 88329ca, commit 0f747f9, commit 19ee294 (22 Aug 2015) by René Scharfe.
Suggested-by: Johannes Schauer .
(Merged by Junio C Hamano -- gitster -- in commit 565f575, 01 Sep 2015)

archive-zip: support more than 65535 entries

Support more than 65535 entries cleanly by writing a "zip64 end of central directory record" (with a 64-bit field for the number of entries) before the usual "end of central directory record" (which contains only a 16-bit field).
InfoZIP's zip does the same.
Archives with 65535 or less entries are not affected.

Programs that extract all files like InfoZIP's zip and 7-Zip ignored the field and could extract all files already.
Software that relies on the ZIP file directory to show a list of contained files quickly to simulate to normal directory like Windows'built-in ZIP functionality only saw a subset of the included files.

Windows supports ZIP64 since Vista.

Here, that should not matter, unless the commit is a very large one.

Upvotes: 0

Klas Mellbourn
Klas Mellbourn

Reputation: 44437

You could use git archive:

git archive --format=zip --prefix MyNewProj/ <oldcommit> -o ../basicproject.zip
cd ..
unzip basicproject.zip
cd MyNewProj
git init

This will create a zip archive of all tracked files (not any ignored, like binaries) at the commit <oldcommit>. Then you can unzip it into a new project.

Upvotes: 1

cforbish
cforbish

Reputation: 8829

You can create a branch from any old point:

git checkout -b topic <oldpoint>

Upvotes: 0

Related Questions