Git merge branch into master

后端 未结 3 763
野性不改
野性不改 2020-12-09 01:30

I have a master branch and a working branch_1. I want to \'move\' branch_1 exactly as it is to master. So I want something like this:<

相关标签:
3条回答
  • 2020-12-09 02:03

    Conflicts are going to happen if both branches have changes to the files. This is a good thing. Keeping your branches up-to-date with each other will prevent some of them . However over all, conflicts are not bad. The rebase option can also prevent many of them from happening.

    git merge branch_1
    

    If you are on master, merging will bring the changes as you expect.

    http://www.kernel.org/pub/software/scm/git/docs/git-merge.html

    You could also

    git rebase branch_1
    

    This will take the changes from branch_1 and append them to master without a merge commit.

    http://www.kernel.org/pub/software/scm/git/docs/git-rebase.html

    0 讨论(0)
  • 2020-12-09 02:19

    Maybe you should not merge?

    1. Checkout branch_1
    2. Rebase master changes into branch_1
    3. Fix any errors that might have occured after testing your code
    4. Checkout master
    5. Rebase branch_1 changes into master

    or in code:

    git checkout branch_1
    git rebase master
    (...)
    git checkout master
    git rebase branch_1
    

    This also gives you the opportunity to squash several commits into one, if you want to make your changesets more dense, and prevents these annoying merge-commits in your history.

    0 讨论(0)
  • 2020-12-09 02:22

    On the command prompt you may type 'git status'. This gives you the current branch that you are working on which is also known as the active branch at this time. Once you execute git merge branch_1, Git will merge branch_1 changes on the active branch.

    Else you could try 'git merge branch_1 master' instead.

    More info about Git merge and overall : https://medium.com/@thisara.udaya/git-under-the-hood-34dbb807330c

    0 讨论(0)
提交回复
热议问题