Let's say I have two existing folders that I want to put under Git
source control. One is called CurrentProduction
and the other CurrentDevelopment
. Would the following steps be correct?
MyProject
git init
CurrentProduction
contents to MyProject
git add .
git commit -m 'initial master commit'
git checkout -b develop
MyProject
(except for the .git folder of course)
CurrentDevelopment
contents to MyProject
git add -A
git commit -m 'initial develop commit'
Or is there a "different" way?
Doing it the way you describe will not do any harm.
You can move the .git
directory into the tree you want to commit instead of moving the tree to the repository.
You can use the --work-tree
option or GIT_WORK_TREE
environment variable to act as if you did that:
git add --work-tree=CurrentProduction -A; git commit ...
Note that it is not necessary to specify it for commands after add
since add
copies content into the index, commit
uses the index, and the index is in .git
.
As a separate issue, note that your procedure will make the develop
initial commit a child of the master
initial commit. That is probably the right thing for this case; I just want to make sure you're aware it's not symmetric.
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