How to create a git branch
高洛峰
高洛峰 2017-05-02 09:28:10
0
6
592

I created a framework and two projects that depend on this framework (actually two script programs)
The framework needs to be placed in the root directory of the script.
The framework and scripts need to be changed frequently now.
Can Git create two different branches for two projects, and on each branch I can see the latest changes to the framework and the respective project (but not the other project)?
Can it Then create sub-branches for respective projects for development with different features of respective projects?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(6)
大家讲道理

Of course you can do this. The code and introduction website of many open source projects are separated in this way on Github. Just add --orphan to Checkout, then clean up this completely independent branch, and the rest can be done on the isolated branch.

git checkout --orphan branchname
git rm --cached -r .

But as everyone suggested, it would be more reasonable to use two repos to handle your situation.

漂亮男人

Why should two projects be put into one repo? You can use two repos, and then put the framework into the project as an external dependency.
If you have to use a repo, the easiest way is to use the framework as a submodule of git, and then have two projects and two branches, with the framework in the root directory. This makes it easier to modify.

世界只因有你

It is recommended to read the Git tutorial carefully. Recommended address:
Git Tutorial

大家讲道理

I guess you are an SVN or CVS user. Git's branching model is obviously different from SVN. It may be more suitable to use multiple Repos to implement functions similar to SVN "branching".

Peter_Zhu

I will give you a simple GIT tutorial, which is enough for daily work. Portal:
Simple GIT tutorial
By the way, I will post my own GIT tutorial, which is very comprehensive. Geek Academy GIT series tutorials

phpcn_u1582

Go directly to sourcetree. The graphical interface is more suitable for getting started. Once you are used to it, you can go to the command line and pretend to be awesome. Creating branches is very simple and clear graphically

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template