简体   繁体   English

Bash脚本命令“ git add --all”抛出错误

[英]Bash script command “git add --all” throws error

I'm trying to run a bash script that I've used on every GIT project I've ever created. 我正在尝试运行一个bash脚本,该脚本已在我创建的每个GIT项目中使用。 It runs an add all, then commits with a given message, then does a push to a mirror on Github. 它运行全部添加,然后提交给定消息,然后推送到Github上的镜像。 For some reason, I've had nothing but problems with this particular project. 由于某种原因,除了这个特定项目之外,我什么都没有。 I've removed every single line of code in the bash script to test this first line, but still get the error. 我已经删除了bash脚本中的每一行代码以测试第一行,但仍然会收到错误。 If I run the command by hand git add --all , it adds all files as you'd expect. 如果我手动运行命令git add --all ,它将按您的期望添加所有文件。 If I run the release.sh , however, it throws a strange error. 但是,如果运行release.sh ,它将引发一个奇怪的错误。 Any help would be appreciated! 任何帮助,将不胜感激!

Contents of release.sh : release.sh内容:

git add --all

Error message on running the bash script: 运行bash脚本的错误消息:

$ bash release.sh
'rror: unknown option `all
usage: git add [<options>] [--] <pathspec>...

    -n, --dry-run         dry run
    -v, --verbose         be verbose

    -i, --interactive     interactive picking
    -p, --patch           select hunks interactively
    -e, --edit            edit current diff and apply
    -f, --force           allow adding otherwise ignored files
    -u, --update          update tracked files
    -N, --intent-to-add   record only the fact that the path will be added later
    -A, --all             add changes from all tracked and untracked files
    --ignore-removal      ignore paths removed in the working tree (same as --no-all)
    --refresh             don't add, only refresh the index
    --ignore-errors       just skip files which cannot be added because of errors
    --ignore-missing      check if - even missing - files are ignored in dry run

edit: This happens with any GIT command I use in this bash script. 编辑:我在此bash脚本中使用的任何GIT命令都会发生这种情况。

I recreated the file and it fixed the problem. 我重新创建了文件,它解决了问题。 Odd. 奇。 I had copied it verbatim from my working copy. 我从工作副本中逐字复制了它。

The file has had lines ending with CR , evident by the closing ' appearing at the start of the error message. 该文件的行以CR结尾,通过在错误消息开头出现的结尾'可以明显看出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM