简体   繁体   English

Git克隆项目到手动复制的文件夹中

[英]Git clone project into manually-copied folder

I'm in the process of deploying a stage site to a production site. 我正在将舞台站点部署到生产站点。 One of my coworkers decided to copy the files using FTP into the production server, however I am tracking the project using git, and I'd like to use the master branch for the production server, but I want to be careful with the files that could have changed. 我的一位同事决定使用FTP将文件复制到生产服务器中,但是我正在使用git跟踪项目,并且我想将master分支用于生产服务器,但是我要谨慎使用可能已经改变了。

I am thinking that this could be a safe approach: 我认为这可能是一种安全的方法:

cd production_dir
git init
git add . -A
git commit -m "Before merge"
git remote add origin git://repourl
git fetch origin
git merge -u origin/master

There's only one restriction: I don't have access to create folders on the ../ path, so I can't do, for example: 只有一个限制:我无权在../路径上创建文件夹,所以我做不到,例如:

git clone git://repourl production_dir_git
cp -r production_dir/* production_dir_git/
rm production_dir && mv production_dir_git production_dir

This is a production ready site so I need to be extra careful. 这是生产准备就绪的站点,因此我需要格外小心。 What's a good and safe approach? 什么是好又安全的方法?

I think, that fetching your origin into initialized repo with one commit will break. 我认为,一次提交将您的来源提取到初始化的回购协议中将会失败。

If you really have to handle this task, I would propose: 如果您真的必须处理此任务,我建议:

copy .git from your repo into your production server directory .git.git复制到生产服务器目录中

git has a beauty, that all lives in that directory. git有一个美丽,所有的人都生活在该目录中。 Immediately after this you shall be able doing $ git status . 此后,您将立即可以执行$ git status

If from your local repo and the production server you see share repo as the same url, you shall then play with fetch etc. 如果从本地仓库和生产服务器看到共享仓库为相同的URL,则应继续使用fetch等。

In case you did in your local repo something, what does not work on production server, you shall find it (and be able to fix it) by reviewing and editing files in root of .git . 如果您在本地存储库中做了某些事情,而这在生产服务器上不起作用,则应通过查看和编辑.git.git文件来找到它(并能够对其进行修复)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM