Git: how to return after merger conflict breaks

OK, as an SVN and CVS specialist for 20 years, I find git a very difficult task. I read a lot of manuals, did not find what is understood. Many apologies for my stupidity with git.

We use only the master, no branches. git was imposed on us.

I have a js file that I “own” and no one should touch it. But someone did this and checked. I tried to check my copy and could not. So I pull out the updated version, which "corrupts" my copy with a lot of <<<and →> entries.

Basically, I wanted to reject all of his changes and overwrite them with mine. with SVN, I just make a copy of my local js file, delete it, extract from the repo to get offensive, copy my copy back and then check the result. Really simple.

I have not found a way to do this in git, as if you deleted the file, it thinks you want to delete it.

So, I tried editing the merged file, but messed up which lines are new and which are old. So now the file is unusable. I "lost" my local copy.

I read about this: "git click the initial -force wizard", but:

  • too late, I already lost my version.
  • , , , , "" someones .

, . , , "git checkout [revision]". , , . , , , , . . , , , , - , , .

, :

  • .
  • , , - , , , ?
+4
3

:

git checkout HEAD my/filename.js

HEAD ( git ), my/filename.js . , , "" . , (no -force , , )

, - , , git add. git ( svn ) < < < " → > " , . , , , , , .

, SVN, , : , git, /filename. JS. ( git), (), ( ) .

+13

, . git , , . , , .

git merge --abort

, , . , , . , - , , .

git log --stat

, .

git revert <commit id>

id, commit, . , , . , , , , .

, .

, , , .

+3

To completely remove external changes in a merge conflict, you can use

git checkout --ours -- <path-to-file> && git add <path-to-file>

This resolves the conflict with a specific file using your version. Adding is necessary to tell git that the conflict is resolved.

+3
source

Source: https://habr.com/ru/post/1532876/


All Articles