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:
git init
git add -A
git commit -m "first commit
git add -A
git commit -m "second commit
git add -A
git commit -m "third commit
Could anyone tell me if this is the best way to do this?
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With