首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从bash中找出是否存在未提交或推送到mercurial存储库的更改?

如何从bash中找出是否存在未提交或推送到mercurial存储库的更改?
EN

Stack Overflow用户
提问于 2013-06-06 21:38:55
回答 1查看 143关注 0票数 0

我希望将此逻辑合并到一个bash脚本中:如果当前存储库有任何本地更改,则停止处理。

代码语言:javascript
复制
#!/bin/bash
set -ex
git pull
git update
# Disallow unstaged changes in the working tree
    if ! git diff-files --check --exit-code --ignore-submodules -- >&2
    then
        echo >&2 "error: you have unstaged changes."
        exit 1
    fi

# Disallow uncommitted changes in the index
    if ! git diff-index --cached --exit-code -r --ignore-submodules HEAD -- >&2
    then
        echo >&2 "error: your index contains uncommitted changes."
        exit 1
    fi
EN

回答 1

Stack Overflow用户

发布于 2013-06-07 08:36:48

这应该可以做到:

代码语言:javascript
复制
if [ -n "$(hg status -mar)" ]
then
    echo >&2 "error: your index contains uncommitted changes."
    exit 1
fi

检查任何移动、添加或删除的文件。如果您想检查已删除(缺失)或未知但不被忽略,您也可以这样做。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16963619

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档