繁体   English   中英

如何在Eclipse中将Web服务器中的文件夹与本地git repo同步?

[英]How to sync folder in the web server with local git repo in Eclipse?

我正在尝试在Eclipse Kepler配置Git,并将我的本地git repo与本地Web服务器中的文件夹同步。

我的本地git存储库中的项目文件夹位于C:\\Users\\MYPC\\git\\mod_helloworld

我的Web服务器文件位于D:\\Install\\xampp\\htdocs\\joomla\\modules\\mod_helloworld

基本上,我将直接在Web服务器文件上工作,并想将mod_helloworld文件夹与本地git repo同步。 我在Eclipse的Git存储库中找不到执行此操作的选项。

如果您希望D:\\Install\\xampp\\htdocs\\joomla\\modules\\mod_helloworldC:\\Users\\MYPC\\git\\mod_helloworld的精确副本,那么可以考虑设置结点链接。

这样做的命令是:

mklink /j D:\Install\xampp\htdocs\joomla\modules\mod_helloworld C:\Users\MYPC\git\mod_helloworld

我建议使用一个临时文件夹尝试一下,看看它如何工作:

mklink /j D:\Install\linked_folder C:\Users\MYPC\git\mod_helloworld

通过以这种方式创建联结,对D:\\ Install \\ linked_folder的所有请求实际上将发送到C:\\ Users \\ MYPC \\ git,但D:\\ Install \\ linked_folder的行为将像普通文件夹一样。

但是,您应该小心,因为这意味着C:\\ Users \\ MYPC \\ git \\ mod_helloworld中的任何更改都将反映在链接的文件夹中,因此,如果您签出开发分支,则服务器文件夹将为您的开发分支文件提供服务,直到您再次签出了稳定版本分支(假设主版本)。

由于这对您而言并不理想,因此可以将C:\\Users\\MYPC\\git\\mod_helloworld文件夹放入裸C:\\Users\\MYPC\\git\\mod_helloworld ,从中将其添加为D:\\Install\\...\\mod_helloworld存储库的远程源如:

cd C:\Users\MYPC\git
mv ./mod_helloworld ./mod_helloworld_backup

mkdir mod_helloworld
cd mod_helloworld
git init --bare

cd D:\Install\xampp\htdocs\joomla\modules\mod_helloworld
git init
git add -A
git commit -m "commiting all server files to server repo"
git remote add folder file:///C:/Users/MYPC/git/mod_helloworld

git push folder master

您现在可以直接作为“本地”存储库处理服务器文件,而后又可以提交/推送到“远程”文件,实际上,这是C:\\ Users \\ MYPC \\ git \\ mod_helloworld

暂无
暂无

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

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