search

Home  >  Q&A  >  body text

How to create a git branch

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?

高洛峰高洛峰2828 days ago603

reply all(6)I'll reply

  • 大家讲道理

    大家讲道理2017-05-02 09:30:10

    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.

    reply
    0
  • 漂亮男人

    漂亮男人2017-05-02 09:30:10

    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.

    reply
    0
  • 世界只因有你

    世界只因有你2017-05-02 09:30:10

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

    reply
    0
  • 大家讲道理

    大家讲道理2017-05-02 09:30:10

    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".

    reply
    0
  • 天蓬老师

    天蓬老师2017-05-02 09:30:10

    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

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-05-02 09:30:10

    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

    reply
    0
  • Cancelreply