Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick and ignoring eol type

Tags:

git

eol

For some totally weird reason I have a file with mixed line endings in my git repository. (At least that is what git diff claims, even though all commits were done with core.autocrlf option set to true.) When I try to cherry-pick a commit it fails due to those line endings:

$ git status
# On branch master
nothing to commit, working directory clean
$ git cherry-pick 77fe281
error: could not apply 77fe281... TFS changeset 9148
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'
$ git status
# On branch master
# You are currently cherry-picking.
#   (fix conflicts and run "git commit")
#
# Changes to be committed:
#
#       modified:   some/other/file.txt
#
# Unmerged paths:
#   (use "git add <file>..." to mark resolution)
#
#       both modified:      Builds/rakefile.rb
#
$ cat Builds/rakefile.rb |grep "<<<"
<<<<<<< HEAD
$ git cherry-pick --abort

As you can see here there are conflicts in Builds/rakefile.rb file. BTW, git claims that all lines in those two files are different, probably due to those different line endings. But at least git is consistent here.

But lets try the same with ignore-all-space option:

$ git status
# On branch master
nothing to commit, working directory clean
$ git cherry-pick 77fe281 --strategy recursive -Xignore-all-space
error: addinfo_cache failed for path 'Builds/rakefile.rb'
U       Builds/rakefile.rb
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm <file>' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
$ git status
# On branch master
# You are currently cherry-picking.
#   (fix conflicts and run "git commit")
#
# Changes to be committed:
#
#       modified:   some/other/file.txt
#
# Unmerged paths:
#   (use "git add <file>..." to mark resolution)
#
#       both modified:      Builds/rakefile.rb
#
$ cat Builds/rakefile.rb |grep "<<<"
$

Here git claims that it could not merge the file, but the file is actually merged (and correctly!). What am I doing wrong?

(rant: git is actually the first VCS that forces me to take care of eol as if we were in 1960's)

like image 665
Tomasz Grobelny Avatar asked Jul 14 '26 13:07

Tomasz Grobelny


1 Answers

This doesn't answer why it thought there were conflicts, but just for others who might be wondering how to ignore line endings with cherry-pick, what you suggested:

git cherry-pick a1b2c3d --strategy recursive -Xignore-all-space

did exactly what I was looking for.

like image 129
sparrowt Avatar answered Jul 18 '26 03:07

sparrowt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!