Git won't let me drain

Good evening!

I know this is a very common thing, and maybe thousands of answers on the Internet, but I could not find what was helfull.

I have two local branches:

  • MASTER
  • Mk

I made many changes to Mk, made them, and switched to MASTER to merge the two branches. But there were conflicts. So, now I am on the MASTER branch, I can no longer switch to Mk, but I need to redefine my MASTER with Mk.

He keeps talking

Error: your local changes in the following files will be overwritten with merge

Is there any way to do this?

git mergetool --tool=meld #No files need merging git merge -s theirs Mk #Could not find merge strategy 'theirs'. git merge -X recursive=theirs Mk # error: Your local changes to the following files 

will be overwritten by merge

and I have not yet made changes to my online repository.

I see a commit with all the changes, but I can’t access its code.

I just started using git some time ago, but I never encountered problems like this before. I would really appreciate any help I can get: s

+4
source share
4 answers

Since there is no --theirs strategy (even if there are ways to simulate )), could you:

  • merge the first master in mk: git checkout mk && git merge -s ours master
  • merge mk for control (fast forward): git checkout master && git merge mk

The -s ours strategy ensures that you keep the mk version in case of conflict.

+7
source

Make sure you are on a clean working copy of MASTER.

 git merge -s recursive -X theirs Mk 
+4
source

I have no idea how file changes were changed for some files in the main branch.

git diff:

 diff --git a/app/Resources/views/base.html.twig b/app/Resources/views/base.html.twig old mode 100644 new mode 100755 

I made the changes made:

 git commit --all -m "changes permissions from 644 to 755" 

After that I was able to merge the branch as if nothing had happened

 git merge Mk 

Although I know that this is not the most elegant solution. But I'm glad my code is back! Now I only need to figure out how to change this permission. Thanks for the great help though!

0
source

Error: your local changes in the following files will be overwritten with merge

This is usually because you have uncommitted changes that will be overwritten. Therefore, first you need to deal with the fact that: (1) commits or (2) writes:

 git add .; git commit -m "committing my workz" # or git add.; git stash 

Now try merging. You may have conflicts. You want all changes from mk take precedence over what's in master , because git is too sensitive to detecting conflicts (for example, no real conflicts) or because someone committing master was dunce:

 git checkout master git merge mk # oh noes! merge conflicts # CONFLICT (content): Merge conflict in foo_bar.txt git checkout mk -- foo_bar.txt git commit 

Boom! Screw master . You are not my master.

Note: git checkout usually used to redirect HEAD (and update the working directory) to the branch / tag / SHA / whatever, but if you do git checkout SHA -- file , it will not reassign your HEAD , instead it will update the file that you will pass after -- to reflect this file / path in the SHA that you pass. You can pass the path instead of the exact file, and it will check all files that differ along this path.

0
source

All Articles