Error "failed to push some refs to '....git'" Is Reported When the Merge Request Is Committed Locally
Symptom
If two people modify the same line of code simultaneously, a code commit conflict may arise when the code is pushed to CodeArts Repo. As a result, the push fails and an error message "failed to push some refs to '....git'" is displayed, as shown in the following figure.
Analysis
A conflict occurs when the same line of the same file is modified (the current version of the local repository is different from that of the CodeArts Repo).
Solution
To resolve a code commit conflict, pull the remote repository to the working directory in the local repository. Git will merge the changes and display the conflicting file content that cannot be merged. Then, modify the conflicting content and push it to the remote repository again (by running the add, commit, and push commands in sequence).
Modify the conflicting file carefully. If necessary, negotiate with the other member to resolve the conflict and avoid overwriting the code of other members by mistake.
git pull combines git fetch and git merge. The following describes the operations in detail.
git fetch origin master # Pull the latest content from the master branch of the remote host. git merge FETCH_HEAD # Merge the latest content into the current branch.
During merge, a message indicating that the merge fails due to a conflict is displayed.
Resolving Merge Conflicts on the Console
- Fix them online (recommended for small code volume)
- Click Fix them online. A code conflict is displayed, as shown in the following figure.
On this page, you can directly select the Apply to Source Branch or Apply to Target Branch to select the modification of one party as the final repaired content.
- If the situation is complex and the problem cannot be solved by simple direct overwriting, click to enter the manual editing mode, as shown in the following figure.
- Manually modify the code to resolve the conflict and commit the changes.
Enter a commit message.
In the preceding figure, the following signs are used for conflict display and separation: <<<<, >>>>, and ====. Delete the lines where the signs are located when modifying code.
- Click Fix them online. A code conflict is displayed, as shown in the following figure.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot