Version control: from zip to git

I have three ZIP folders with the name [1,2,3], each of which contains the same project 1, which is the earliest and 3 the very last. I am looking for a way to combine all of them into 3 git commits, and the 3 most commits are the contents of the folders.

I believe I can do the following:

  • Unzip 1.
  • Take the contents from 1 place to a new folder.
  • git init
  • git add -A
  • git commit -m "first commit
  • Unzip 2
  • replace the contents of the new folder with the contents of 2
  • git add -A
  • git commit -m "second commit
  • Unzip 2
  • replace the contents of the new folder with the contents of 3
  • git add -A
  • git commit -m "third commit

Can someone tell me if this is the best way to do this?

+4
source share
4 answers

Each time you run git init , you create an empty repository.

If there are only three folders, and you only do it once, this will work (if you omit git init ). Just don't delete the .git folder.

You can even unzip the three folders and move the .git folder to each individual folder one by one, and the destination folder is the beginning of your new repository.

+2
source

Unzip the three ZIP files into three different directories.

Initialize the git repository in the fourth directory.

Then use the --work-tree option, which allows you to execute the git command from the git repo, but with content outside the specified 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 other content without moving from the git directory!

+5
source

This is how I would approach this

Get the completed version 1

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

Get version 2

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

Get version 3

Repeat the above for version 3 of the zip file.

+4
source

Yes. Just make sure to completely replace the contents, and catch all the added and deleted files.

0
source

Source: https://habr.com/ru/post/1391904/


All Articles