我感兴趣的是创建一个别名来添加所有文件、提交消息、 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/