Why is the Git talking file “deleted by us” when I haven’t touched it?

I adjusted 2 files and went to combine them on Github. However, when I run push, I get an error message:

Unmerged paths:
#   (use "git add/rm <file>..." as appropriate to mark resolution)
#       deleted by us:   somefolder/somefile.ext

However, I did not touch this file. When I look at my local directory, I see that the file is still very intact.

Does anyone know why this is happening and what can I do about it?

+4
source share
2 answers

See " Who" us "according to git? "

When you merge, it usrefers to the branch you merge into, unlike them, the branch that you want to merge.

Therefore, the destination branch should delete this file.

. "git merge ", " " : .

torek , "" ( ) rebase (, git pull --rebase).

. "git rebase, "local" 'remote'"

  • local ( "us" ) : "" ( )
  • remote ( "them" ) : "" - , .. , .
+4

:

2 , Github.

Git. git commit, ( ). git fetch Git (, GitHub), . . . , .

, - git merge git rebase, - - (, git pull) git merge git rebase , :

... push, [ Unmerged paths]

, . --rebase , , , .

:

  • git merge, git rebase? , deleted by us , , .

  • , , , ?

"/" , - , , , . - , - , . .

, git rebase, , git pull ( git fetch, git merge, git rebase , git pull).

, , - . , , , , , , . , master:

          H--I   <-- master
         /
...--F--G

H I - . , , , Git , , - Git, commit G:

          H--I   <-- master
         /
...--F--G   <-- origin/master

git fetch. Git, . J K :

          H--I   <-- master
         /
...--F--G--J--K   <-- origin/master

"" (commit H) "" (commit I). : git merge git rebase. merge , , , Git .

Git . , master "" origin/master. , ( ) -- , . G.

Git:

git diff G I   # figure out what "we" did on master
git diff G K   # figure out what "they" did on origin/master

Git . , "" README, "" . , . : , README commit G. , Git , .

, Git README. master :

          H--I--L   <-- master
         /     /
...--F--G--J--K   <-- origin/master

, "" ( H--I) "" ( J--K), README, somefile.ext somefile.ext. /: Git , G G. Git , L , , somefile.ext " ".

, Git :

    deleted by them: somefile.ext

, "" H--I. Commits J--K , ( , - ).

Git somefile.ext , . git add git rm , . git commit, , , /. commit L, ( ) .

Rebase ,

, git rebase.

Git - , , , ( H--I), , , Git . (Git , .)

Git :

git checkout <hash-of-K>

:

git cherry-pick <hash-of-H>

, H README. commit K, "" . commit H . Git: H , , H. Git , , . Git H, H', :

          H--I   [somewhat in limbo]
         /
...--F--G--J--K   <-- origin/master
               \
                H'  <-- HEAD

Git cherry-pick I. , somefile.ext. commit H', commit K, somefile.ext. ! , Git .

somefile.ext? commit I, ( "" ) , . somefile.ext? , , K ( J K), Git, . somefile.ext. , Git :

    deleted by us: somefile.ext

, Git . Git , somefile.ext, . , J--K H--I. git add git rm , , git cherry-pick . , git commit, git rebase --continue.

Git rebase, I' , I. : , , I, somefile.ext, somefile.ext, commit . git rebase --continue , , , git rebase --skip commit I.

, (--continue I I' skip I), :

          H--I   [abandoned]
         /
...--F--G--J--K   <-- origin/master
               \
                H'--I'  <-- master

I'.

git push , , .

+3

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


All Articles