Git 应用程序前端/后端共享代码库
我对 git 相当陌生,有以下问题:
我正在开发一个 HTML/JS 应用程序。对于后端,我想与前端共享相同的代码库(像jquery、存根index.html、几个帮助文件、标准css这样的库)
所以我想包含代码库存储库并拥有一个自己的存储库来存储顶部的所有更改(总共 3 个存储库:1 个代码库、1 个前端、1 个后端)。就像应用程序骨架一样。 这可以通过子模块实现吗?我希望能够将更改推送到代码库或项目存储库。
例如:
public/
|_ index.html
|_ css/
|_ styles.css
如果我更改index.html以包含与代码库一起使用的js库,我希望能够推送到代码库。如果我更改 index.html 的标题标签,我希望能够将该更改推送到项目存储库,并使代码库不受影响。
I am fairly new to git and have the following question:
I am developing a HTML/JS application. For the Backend I want to share the same codebase as the frontend (libs like jquery, a stub index.html, several helper files, standard css)
So i want to inlude the codebase repository and have an own repository for all changes on top (3 repositories alltogether: 1 codebase, 1 frontend, 1 backend). Like an application skeleton.
Is this achievable with submodules? I want to have the possibility to push changes to the codebase or the project repository.
For example:
public/
|_ index.html
|_ css/
|_ styles.css
If I change the index.html to include a js lib to use with the codebase I want to be able to push to the codebase. If I change the title Tag of the index.html I want to be able to push that change to the projects repository and leave the codebase unaffected.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
子模块是重用独立文件集的好方法,但您不应该混合子模块和您需要的实际目录结构。
这与您的实际结构不同
您可以通过符号链接(甚至在 Windows Vista 或 7 上也存在)将两者链接在一起,以便修改您常用目录中的内容,但要在实际的 Git 存储库工作树中提交。
Submodules are a good way to reuse independent set of files, but you shouldn't mix submodules and the actual directory structure you will need.
This is different from your actual structure
The way you can link both together is through symlinks (which exists even on Windows Vista or Seven), in order to modify what you want in your usual directories, but to commits in the actual Git repo working trees.
是的,子模块就可以了。我不需要使用符号链接。我有一个包含第 3 方 dll 的子模块,一个包含包括后端在内的通用代码的子模块,一个包含应用程序逻辑的子模块。
一句建议是,不要在目录名称中使用空格。
Yes, submodules will do. I have not needed to use symlinks. I have one submodule that houses 3rd party dlls, one that houses common code including backend and one that has the app logic.
One word of advice, don't use spaces in your directory names.