Merging 2 branches together in GIT

后端 未结 3 1070
心在旅途
心在旅途 2020-12-12 09:52

I\'ve only just started to use GIT and think its wonderful, however I\'m a little confused over what the merge command does.

Let us say we have a workin

3条回答
  •  伪装坚强ぢ
    2020-12-12 10:13

    Case: If you need to ignore the merge commit created by default, follow these steps.

    Say, a new feature branch is checked out from master having 2 commits already,

    • "Added A" , "Added B"

    Checkout a new feature_branch

    • "Added C" , "Added D"

    Feature branch then adds two commits-->

    • "Added E", "Added F"

    Now if you want to merge feature_branch changes to master, Do git merge feature_branch sitting on the master.

    This will add all commits into master branch (4 in master + 2 in feature_branch = total 6) + an extra merge commit something like 'Merge branch 'feature_branch'' as the master is diverged.

    If you really need to ignore these commits (those made in FB) and add the whole changes made in feature_branch as a single commit like 'Integrated feature branch changes into master', Run git merge feature_merge --no-commit.

    With --no-commit, it perform the merge and stop just before creating a merge commit, We will have all the added changes in feature branch now in master and get a chance to create a new commit as our own.

    Read here for more : https://git-scm.com/docs/git-merge

提交回复
热议问题