I clone a repository in my machine and created a new_branch and commit 2 changes and tried to push my new branch to the repository.
git push origin new_branch
Then I tried to merged the new branch in my remote master branch but it say merge conflict
my master branch is uptodate but still saying merge conflict
CodePudding user response:
Try first to rebase locally your new branch on top of an updated master
(or main
, if you have created the repository recently, since the default branch naming convention has changed).
cd /path/to/local/clone
git fetch
git switch new_branch
git rebase origin/master
git push --force
From there, a merge to GitHub master
should have no conflict, because any conflict would have been resolved locally first.
CodePudding user response:
The merge conflict is occurring because you have made separate changes in the same line of a file git is not sure which one to discard. Write
git status
to see the conflicts and resolve them by removing the older file