Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push rejected, merge conflicts, git pull --rebase

I'm trying to push my commit, but couldn't since there is another commit (same-level in the HEAD race :)

I know I need to merge those two commits together, not exactly sure how to do it.
I already tried git pull --rebase.

My GIT-CLI:

git cli

like image 538
Hi_im_MrMee6 Avatar asked Jul 20 '17 04:07

Hi_im_MrMee6


People also ask

Does git rebase cause merge conflicts?

When you perform a git rebase operation, you're typically moving commits around. Because of this, you might get into a situation where a merge conflict is introduced. That means that two of your commits modified the same line in the same file, and Git doesn't know which change to apply.

What conflicts can occur when forcing a push after rebasing?

While this happens, conflicts may arise. These are conflicts between your code changes in the PR and other changes that got merged into the target branch. What you could do is merge the changes from the target branch into your PR branch. That will however give a lot of merge commits and isn't very clean.

What is difference between pull merge and rebase?

Merging is a safe option that preserves the entire history of your repository, while rebasing creates a linear history by moving your feature branch onto the tip of main .


1 Answers

All you need to need to do is solving the conflict you see mentioned at the end of your pull --rebase.
See "HOW CONFLICTS ARE PRESENTED": you will have to open those files, and remove the conflict markers.
For the .tern-port file, you need to decide if you want to keep your file, and remove it, as it has been removed in the upstream repo.

I forgot to configure my .gitignore file.

If you realize that because of tracked files that should not be tracked, don't forget to un-track them first, before adding them to your .gitignore

git rm --cached -- afile
echo afile >> .gitignore
git add .gitignore

That can be done during your conflict resolution stage.

Once that stage is done, add them (git add .), and continue the rebase (git rebase --continue).
After that, if the git status is clean, you can push.

like image 123
VonC Avatar answered Sep 30 '22 21:09

VonC