0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

バッチファイルをGitでチェリーピックしたら動かなかった失敗

Posted at

現象

バッチファイルをgit commitして、別のブランチからgit cherry-pickをしたらバッチファイルが動かなくなった

::サンプルバッチ
@echo off
set SOURCE=C:\source\file.txt
set DEST=C:\destination\file.txt
copy /Y "%SOURCE%" "%DEST%"
exit /b 0

原因

git config core.autocrlfで改行コード変換の設定を見るとinputになっている。
どうやらinputだとgit commit時に改行コードがLFに変換される模様。
(参考)
https://qiita.com/uggds/items/00a1974ec4f115616580

解決方法

git config core.autocrlftrueにした。
チェリーピックをしたら正常実行されることを確認した。

反省

バッチファイルをメモ帳で開いていたため改行コードが変わっていることに暫く気付かなかった。
VSCodeやサクラエディタで開いてたら気付けたかなー。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?