What to do when commit conflicts in Git?

Asked 1 years ago, Updated 1 years ago, 37 views

There is a remote repository ("Remote" here), and I and Mr. A are using this using Github.
However, A and I had different commitment history in the local repository, which caused conflict.This is the current situation.
·My commitment history
Commit A
Commit B
Commit E
Commit F

·Commit history of friend A
Commit C
Commit D
Commit E
Commit F

·Remote Status
The commit A that I pushed is reflected (I used push-f)

Commit A is a newer commit than commit C, and
Commit B is a newer commit than commit D.

There are some changes to commit C that commit A does not have, and I would like to reflect them.
I am at a loss what to do because the commit interfered.
I also tried rebase, but it didn't work.

How can I combine(?) the commitment between me and my friend A?
Also, is it possible to reflect the changes in Commit C in the current Remote?
I'm sorry for the confusing and confusing writing, but
If anyone understands, please reply.

git

2022-09-30 19:48

3 Answers

I thought I should give you a specific example.

Suppose you and your friend A were both developing at the master branch.
Also, assume that the remote repository was configured with origin.

Friend A should do the following.

 git fetch
git merge origin/master

# If a conflict occurs, check the git status to see what is unmerged.
# Modify the conflict in that file.
# (You can easily tell where the conflict is by looking at the file.)
# Git add the file after making the correction

# Final commit required if conflict was occurring
# If there is no conflict, at the time of git merge,
# A commit should have been created.
git commit

git push

This will push a (merge) commit to Remote that seems to integrate the history of ABEF and CDEF.


2022-09-30 19:48

Conflicts cannot be resolved automatically and must be merged at human discretion.

You and your friend push to different branches
Modify (manually merge) to what should be compared to
If there is no problem, why don't you merge it into a main branch?


2022-09-30 19:48

It's not about GitHub, it's about Git.

Think about how to resolve conflicts and what sources you want to complete (discuss with project members if necessary).

I can't say for sure what files are conflicted and what I want to do, but at least I don't think I'll use push-f or rebase unless there's too much conflict.

Basically,
The Git option is
--ours
--theirs
and so on.

If the above options do not meet the requirements, editing the source file directly in the editor is a common practice.


2022-09-30 19:48

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.