首先,我是Git的新手。事情就是这样:
我们最近迁移到新服务器或实时站点,我们没有阶段实例。
所以我希望有一个子域用于登台(或QA),另一个子域用于开发。
我已经初始化了一个--bare
存储库,我的问题是,¿如何将我的网站添加到此存储库中?
我不是从我的本地计算机添加,因为该网站的大小为15 GB。所以,这会浪费很多时间。
之后,我假设我需要将存储库克隆到每个子域中,并分别结帐到阶段和开发阶段,不是吗?
现在我有了这个:
/var/www/html/live/ (All site files)
/var/www/html/repository.git/
/var/www/html/stging/ (empty)
/var/www/html/dev/ (empty)
答案 0 :(得分:1)
这通常通过主裸仓库/var/www/html/repository.git/
内的3个分支来完成。
如果该裸仓库是空的,您想要使用您的实时文件夹的内容进行第一次提交:
export GIT_DIR=/var/www/html/repository.git
git config --bool core.bare false
git config user.name yourUserName
git config user.email yourEmail
cd /var/www/html/live
# edit a .gitignore file, listing big files and folders you should ignore
git add .
git commit -m "Live repo import"
# Make two other branches
git branch dev
git branch stg
# restore the bare repo nature
git config --bool core.bare true
unset GIT_DIR
然后您可以在非裸实例中克隆您的仓库:
cd /var/www/html/live
# no need to checkout HEAD: the files are already there
git clone --no-checkout /var/www/html/repository.git
cd /var/www/html/stging/
git clone --branch stg /var/www/html/repository.git
cd /var/www/html/dev/
git clone --branch dev /var/www/html/repository.git