Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Version control: from zip to git

I have three zipped folders named [1,2,3] each contains the same project 1 being the earliest and 3 being the most current. I am looking for a way to merge all of these into 3 git commits and the 3 most commit be the folders contents.

I suppose I can do the following:

  1. Unzip 1.
  2. Take the contents from 1 place it into a new folder.
  3. git init
  4. git add -A
  5. git commit -m "first commit
  6. Unzip 2
  7. replace the contents from the new folder with contents from 2
  8. git add -A
  9. git commit -m "second commit
  10. Unzip 2
  11. replace the contents from the new folder with contents from 3
  12. git add -A
  13. git commit -m "third commit

Could anyone tell me if this is the best way to do this?

like image 712
ThomasReggi Avatar asked Dec 22 '22 03:12

ThomasReggi


2 Answers

Unzip your three zip file in three different directories.

Initialize a git repo in a fourth directory.

Then take advantage of the --work-tree option, which allows you to execute a git command from a git repo, but with a content located outside of said git repo:

cd /your/git/repo
git add --work-tree=/path/to/zip1 -A .
git commit -m "Add v1"
git add --work-tree=/path/to/zip2 -A .
git commit -m "Add v1"
git add --work-tree=/path/to/zip3 -A .
git commit -m "Add v3"

In other words, you can add different contents without moving from your git directory!

like image 102
VonC Avatar answered Jan 03 '23 02:01

VonC


Here's how I would approach this

Get Version 1 commited

mkdir MyProj
cd MyProj
git init
# unzip version1 into MyProj
git add -A
git commit -m "Version 1"

Get Version 2 committed

# delete everything but the .git directory in MyProject
# unzip version2 into MyProj
git add -A 
git commit -m "Version 2"

Get Version 3 committed

Repeat the above for version3 of the zip file.

like image 23
JaredPar Avatar answered Jan 03 '23 02:01

JaredPar