How do I resolve merge conflicts with git?

Asked

Viewed 6,802 times

5

I had a merge conflict problem in git. This problem happened when two people were making the same modifications to the same file. The first person committed and I went to do another commit after it. git refused and I tried three more times. The fourth time git let the commit be performed, but the web system had a broken part.

So I did a revert on a working commit and after that, I did a checkout for the same commit that was working. But now when I give git push, it appears that the directory is empty and has nothing to go up.

Does anyone have a solution to get the repository back to normal ? Thank you.

  • Is the master a third branch, or is it one of yours?

  • first very important detail, always pull before push. Another tip to avoid this type of situation is to use git stash to put the changes in a stack if you need to recover them after that.

  • 1

    master is a branch of mine. Thanks for the @pmargreff tip. I managed to fix it. I used the following git push -f origin <commit> :master command. Thanks for the comments.

  • You can answer your own question in this case, so you help those who have the same problem in the future.

1 answer

2


I figured it out. I used the following git push -f origin command:master So my remote branch goes back to the desired commit and when I clone the project I’ll start from that commit.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.