How to move the current working branch to master branch in git

后端 未结 10 1028
挽巷
挽巷 2020-12-13 00:13

I have currently one of the project it contain more branches. master branch not yet merger long time. So i want switched to master with latest code.

Can you please g

10条回答
  •  遥遥无期
    2020-12-13 00:40

    If you want to have in master exactly the same files state as in other_branch and save history - do the following (and note the period at the end):

    git checkout master
    git checkout other_branch .
    

    Now you will have a full copy of other_branch in current master (it is softer than reset), not yet committed. Then make a regular commit:

    git add --all
    git commit -m "* copy other_branch to master working tree"
    

    Note: untracked (unindexed) files (directories) from other_branch will remain, if they are not tracked by master. To remove those untracked files (directories):

    git clean -fd
    

    See How to remove local (untracked) files from the current Git working tree? for more details.

提交回复
热议问题