在现有非Git项目上进行Git克隆

在现有非Git项目上进行Git克隆,git,deployment,git-clone,Git,Deployment,Git Clone,事情是这样的。我有一个在服务器上运行的旧php应用程序。我把php文件复制到我的计算机上,并用它制作了git。(git init和push到我们的git服务器)现在是棘手的部分,服务器无法git push(仅使用deploy键进行pull),但文件仍然在服务器上。我对我的git repo添加了一些修改(一些快速修复),并希望将它们应用到我的非git php应用程序中 这可能吗 我在考虑git init,在服务器上添加,然后添加一个remote和pull,但我很确定它只会解决每个文件之间的冲突 谢

事情是这样的。我有一个在服务器上运行的旧php应用程序。我把php文件复制到我的计算机上,并用它制作了git。(git init和push到我们的git服务器)现在是棘手的部分,服务器无法git push(仅使用deploy键进行pull),但文件仍然在服务器上。我对我的git repo添加了一些修改(一些快速修复),并希望将它们应用到我的非git php应用程序中

这可能吗

我在考虑git init,在服务器上添加,然后添加一个remote和pull,但我很确定它只会解决每个文件之间的冲突


谢谢

如果您在服务器上执行一个
git init
,然后添加、提交,然后创建一个分支,该分支与您想从repo中签出的分支不同,只是为了备份,那么您可以签出您想要的分支。应该可以

因此,在服务器上:

cd /path/to/repository
git init
git checkout -b server-backup
git add -a # or something more precise to ignore what needs to be ignored, etc.
git commit -m 'Backup commit from server'
git branch -D master
git remote add origin user@central.repo:project
git fetch origin
git push -u origin server-backup
# *
git checkout branch-you-want-to-deploy
*为了非常安全,在执行最后一步之前,您可能需要打开机箱,验证服务器备份和分支之间的差异是否是您真正想要部署的

# on client
git fetch origin
git diff server-backup..branch-you-want-to-deploy

谢谢,我不知道这怎么行。好主意P