使用 git 维护项目骨架的最佳方法
几年来,我一直在寻找管理我正在从事的多个项目的方法。每个应用程序都在某些方面有所不同,但应用程序的核心是共同的。当我在当前项目中实现一些新功能时,很难在以后的其他项目中使用它们。我必须搜索许多项目才能真正找到该功能。
然后git出现了,它对提高我的项目管理帮助很大。我创建了一个框架项目,其中实现了整个应用程序结构以及核心库、工具和模块。这是我开始的每个新项目的基础。它看起来像这样:
mkdir new_project
cd new_project
git init
骨架合并的时间:
git remote add skeleton git@domain:skeleton.git
git fetch skeleton
git merge skeleton/master
现在是项目调整、更改 ini 文件、添加自定义模板、模块、演示者等。现在项目过着自己的生活。一段时间后,与更新的骨架合并:
git fetch skeleton
git merge skeleton/master --no-commit
我喜欢检查从骨架到项目的所有更改,因此 --no-commit 选项。
现在我的问题来了。 维护骨架的最佳方法是什么? 当向每个使用骨架作为基础的项目添加新功能时,有些功能仅与当前项目相关。但是应用程序的核心有一些功能,我在下一个项目中也需要它们,因此我需要将它们合并到骨架中。
我没有在 git/merge 或任何其他 git 命令中找到任何方法来维护骨架。因此,我手动将项目与骨架进行比较(使用 meld,虽然是很棒的工具)并应用针对骨架的更改,然后我致力于骨架。
我尝试维护骨架以将项目添加为远程,获取项目,然后合并到骨架,但这样对项目的所有更改(仅适用于项目)都会返回到骨架,这是无效的。
For few years I was looking for way to manage multiple projects I'm working on. Every single one is different in some way, but the core of application in common for all. When I implemented some new features in current project, it was hard to use them in later in other project. I had to search through many projects to actually find the feature.
Then came git and it helped a lot to improve my project's management. I created one skeleton project, where the whole application structure and core libraries, tools and modules are implemented. It's a base for each new project I'm starting. It looks like this:
mkdir new_project
cd new_project
git init
Time for skeleton to merge:
git remote add skeleton git@domain:skeleton.git
git fetch skeleton
git merge skeleton/master
Now here comes project tweaking, changing ini files, adding custom templates, modules, presenters and so on. Now project lives it's own life. After some time comes merging with updated skeleton:
git fetch skeleton
git merge skeleton/master --no-commit
I like to review all changes coming from skeleton to project, therefore --no-commit option.
And now my question comes. What is the best way to maintain skeleton ? When adding new features to each project that uses skeleton as a base, there are features, that are only related to current project. But there are features to the core of application and I will need them in my next project as well, therefore I need to merge them to skeleton back.
I didn't find any way in git/merge or any other git's command to maintain skeleton. So I'm manually comparing project with skeleton (using meld, great tool though) and applying changes that are meant for skeleton, then I'm committing to skeleton.
I tried to maintain skeleton to add project as remote, fetch project and then merge to skeleton, but this way all the changes to project, that are for project only are coming back to skeleton and that is invalid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法可能是在项目中创建一个名为
骨骼改进
的新分支。当您在处理项目时对骨架进行改进时,请在改进分支上进行。然后,将其合并到您的主干(或工作分支,等等)中:当您想要更新骨架存储库时,将您的项目添加为远程项目,获取,然后合并骨架改进分支。
One approach might be to make a new branch in your project called
skeleton-improvements
. When you make an improvement to the skeleton while working on a project, do it on the improvements branch. Then, merge it into your master (or working branch, whatever):When you want to update the skeleton repo, add your project as a remote, fetch, and then merge the
skeleton-improvements
branch.