git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git apply -3 doesn't work

From
KKKonstantin Kharlamov <hi-angel@yandex.ru>
Date
May 8, 2020, 10:35 UTC
Message-ID
<d9d549eb-e888-c930-1aeb-38cd3aad1b3b@yandex.ru>
As description says. To check that the 3-way merge should actually work subsitute `git apply -3` with `git am -3` in the following steps. This way it works.
# Steps to reproduce
     $ git init
     Initialized empty Git repository in /tmp/foo/.git/
     $ echo hello > file1 && git add file1 && git commit -m "initial commit"
     [master (root-commit) 8334093] initial commit
      1 file changed, 1 insertion(+)
      create mode 100644 file1
     $ git checkout -b mybranch
     Switched to a new branch 'mybranch'
     $ echo bye > file1 && git add file1 && git commit -m "change file1 text"
     [mybranch 1807900] change file1 text
      1 file changed, 1 insertion(+), 1 deletion(-)
     $ git format-patch -1 --stdout > 1.patch
     $ git checkout master
     Switched to branch 'master'
     $ mv file1 file2
     $ git add -u && git add file2 && git commit -m "renamed file1 to file2"
     $ git apply -3 1.patch
     error: file1: does not exist in index
## Expected
Git apply successfully returns
## Actual
It prints
	error: file1: does not exist in index
# Versions
git 2.26.2
Next: Phillip Wood
Message 1 of 3 in “git apply -3 doesn't work”
  1. Konstantin KharlamovMay 8, 2020
  2. Phillip WoodMay 8, 2020
  3. Konstantin KharlamovMay 8, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.