💽 CICD/Git

[Git] fatal: push options must not have new line characters

heywantodo 2024. 4. 24. 15:20
728x90
반응형

[Git] fatal: push options must not have new line characters

 

Merge Request 를 command Line으로 생성하는 법을 포스팅 했었다.

 

[Git] Merge Request command Line으로 생성하기

[Git] Merge Request command Line으로 생성하기 자동으로 MR 생성을 해야하는 과제가 있었다. 찾아보니 gitlab 11.10 부터 git 2.10 이상을 사용하는 경우, 다음과 같이 CLI로 Merge Request를 생성할 수 있었다. git p

heywantodo.tistory.com

git push \
-o merge_request.create \
-o merge_request.remove_source_branch \
-o merge_request.title="[Title]"
-o merge_request.description="[Description]"
-o merge_request.targe=[target branch name] \
origin [source branch name]

 

push를 하는 과정에서 문제가 발생했는데, -o merge_request.description 명령어에서

description에 개행(/n)이 들어가면 다음과 같은 오류가 발생했다.

fatal: push options must not have new line characters

 

git push 옵션에서 개행을 허용하지 않는 것으로 보였다.

이를 해결하기위해선 개행을 <br />로 대체해주면 된다.

description.replace("\n", "<br />")

 

참고

https://stackoverflow.com/questions/71646431/how-to-supply-a-text-file-with-newlines-as-input-to-git-push-options

728x90
반응형