How to work simultaneously on a few branches

前端 未结 4 1800
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 06:40

This is a follow-up on this question on creating branches.

It strikes me as odd that I would still work on one repository because the files on my local machine will be a

4条回答
  •  梦谈多话
    2021-01-30 07:02

    Your concern about 'the files on my local machine will be a weird mix of different experiments.' is unfounded - if you have branch 2 checked out, you will not see the files of branch 1 at the same time.

    I would do something like

    # on master branch
    git checkout master
    # Create a branch for feature 1
    git checkout -b feature_1
    # work on feature 1
    
    # Start a new feature branch
    git checkout master
    git checkout -b feature_2
    # work on feature 2
    
    # feature 2 finished and committed, time to merge 
    git checkout master
    git merge feature_2
    
    # update feature_1 branch
    git checkout feature_1
    git merge master
    

提交回复
热议问题