git:如何将外部目录添加到存储库? [英] git: How do you add an external directory to the repository?

查看:996
本文介绍了git:如何将外部目录添加到存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



外部目录:
/ home / some /目录



工作目录:
/htdocs/.git



如果我从/ htdocs目录尝试以下命令:


git add / home / some / directory

我得到一个错误:
致命:'/ home / some / directory'在外部存储库

解决方案

做这样的事情,我通常会将该外部文件或目录移动到我的git repo中,并将它的原始位置符号链接到新的位置。

  mv / home / some / directory / htdocs /目录
ln -s / htdocs / directory / home / some /
git add ./directory

当我为一个应用程序开发一个插件时,我使用这种技术,该应用程序需要在版本控制下保存,但必须存储在特定位置。 / p>

I want to add an external directory to an existing repository.

External Dir: /home/some/directory

Working Dir: /htdocs/.git

If I attempt the following command from the /htdocs dir:

git add /home/some/directory

I get an error: fatal: '/home/some/directory' is outside repository

解决方案

If I need to do something like that I would normally move that external file or directory into my git repo and symlink it's original location to the new one.

mv /home/some/directory /htdocs/directory
ln -s /htdocs/directory /home/some/
git add ./directory

I use this technique when I am developing a plug-in for an application that I want to keep under version control but have to store in a specific location.

这篇关于git:如何将外部目录添加到存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆