gpt4 book ai didi

Git 别名链添加、提交、 pull 、推送?

转载 作者:太空狗 更新时间:2023-10-29 14:27:15 27 4
gpt4 key购买 nike

我感兴趣的是创建一个别名来添加所有文件、提交消息、 pull ,如果有任何冲突停止并显示冲突文件列表,否则推送。

我已经找到了一个别名来列出冲突的文件(git config --global alias.conflicts "diff --name-only --diff-filter=U"),但我没有了解如何集成其余命令。

甚至可以用这种格式创建 if 语句吗?

伪代码(多行以提高可读性):

git config --global alias.commitall '!func(){ git add -A && git commit -am "$1" &&
git pull && <conflict detection and possible die of command> &&
git push; }; func'

最佳答案

不需要在别名中添加冲突检查。如果在 git pull 上检测到冲突,那么它会自动 echo 找出有冲突的文件并停止。这允许将别名缩减为以下内容(多行以提高可读性):

git config --global alias.commitall '!func(){ git add . && git commit -aqm "$1" &&
git pull -q --no-progress && git push -q; }; func'

我已经添加了 -q 参数来阻止调用回显正常的 bumpf,但这是首选。

用法:

git commitall "message goes here"

关于Git 别名链添加、提交、 pull 、推送?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21552157/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com