Git merge errors

前端 未结 5 2059
刺人心
刺人心 2020-12-12 08:38

I have a git branch called 9-sign-in-out with perfectly working code, and I want to turn it into the master. I\'m currently on the master branch.



        
相关标签:
5条回答
  • 2020-12-12 08:51

    git commit -m "Merged master fixed conflict."

    0 讨论(0)
  • 2020-12-12 08:53

    Change branch, discarding all local modifications

    git checkout -f 9-sign-in-out 
    

    Rename the current branch to master, discarding current master

    git branch -M master 
    
    0 讨论(0)
  • 2020-12-12 09:00

    my issue was (master|REBASE 1/1)

    this command worked for me

     git rebase --skip
    
    0 讨论(0)
  • 2020-12-12 09:14

    It's worth understanding what those error messages mean - needs merge and error: you need to resolve your current index first indicate that a merge failed, and that there are conflicts in those files. If you've decided that whatever merge you were trying to do was a bad idea after all, you can put things back to normal with:

    git reset --merge
    

    However, otherwise you should resolve those merge conflicts, as described in the git manual.


    Once you've dealt with that by either technique you should be able to checkout the 9-sign-in-out branch. The problem with just renaming your 9-sign-in-out to master, as suggested in wRAR's answer is that if you've shared your previous master branch with anyone, this will create problems for them, since if the history of the two branches diverged, you'll be publishing rewritten history.

    Essentially what you want to do is to merge your topic branch 9-sign-in-out into master but exactly keep the versions of the files in the topic branch. You could do this with the following steps:

    # Switch to the topic branch:
    git checkout 9-sign-in-out
    
    # Create a merge commit, which looks as if it's merging in from master, but is
    # actually discarding everything from the master branch and keeping everything
    # from 9-sign-in-out:
    git merge -s ours master
    
    # Switch back to the master branch:
    git checkout master
    
    # Merge the topic branch into master - this should now be a fast-forward
    # that leaves you with master exactly as 9-sign-in-out was:
    git merge 9-sign-in-out
    
    0 讨论(0)
  • 2020-12-12 09:17

    as suggested in git status,

    Unmerged paths:                                                                                                                                
    (use "git add <file>..." to mark resolution)                                                                                                 
    
        both modified:   a.jl                                  
        both modified:   b.jl
    

    I used git add to finish the merging, then git checkout works fine.

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