Windows/bash 中出现意外的问号
我正在尝试使用Windows上的Mingw Bash自动在Windows上“存档”一些本地分支。
我在txt文件(branches_to_be_archived.txt
)上复制并粘贴了git分支
的
#!/bin/bash
BRANCH_NAME=$1
echo "Branch name is $BRANCH_NAME"
git tag archive/$BRANCH_NAME $BRANCH_NAME
git branch -D $BRANCH_NAME
内容从文件中,
#!/bin/bash
FILE=./branches_to_be_archived.txt
LINES=$(cat $FILE)
for LINE in $LINES
do
./archive_branch.sh.txt $LINE
done
我插入了一些回声打印,它们还可以,但是执行git命令会引起这样的错误:
fatal: Failed to resolve '[actual name of the branch]?' as a valid ref.
拖尾?在任何地方都没有显示。
有什么办法避免在最后有这个问号吗?
I'm trying to automatically "archive" some local branches on Windows using the MinGW Bash on Windows.
I copy and pasted the content of git branch
on a txt file (branches_to_be_archived.txt
) and then I wrote:
A script to archive a single branch
#!/bin/bash
BRANCH_NAME=$1
echo "Branch name is $BRANCH_NAME"
git tag archive/$BRANCH_NAME $BRANCH_NAME
git branch -D $BRANCH_NAME
A script to archive every branch from a file
#!/bin/bash
FILE=./branches_to_be_archived.txt
LINES=$(cat $FILE)
for LINE in $LINES
do
./archive_branch.sh.txt $LINE
done
I inserted some echo prints and they are ok but executing git commands will raise an error like this:
fatal: Failed to resolve '[actual name of the branch]?' as a valid ref.
With a trailing ? that is not shown anywhere.
Any way to avoid having this question mark at the end?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实上,这是一个尾行字符问题(Win
CRLF
和 LinuxLF
)。我通过使用
Notepad++
并设置EOL -> 解决了这个问题Linux (LF)
但我认为分支列表文件的dos2unix
工作得很好Indeed, it was a endline characters issue (Win
CRLF
and LinuxLF
).I solved by using
Notepad++
and settingEOL -> Linux (LF)
but I think thatdos2unix
for branches list file works just fine