gpt4 book ai didi

git - 用 git up 替换 git pull

转载 作者:太空狗 更新时间:2023-10-29 12:54:42 26 4
gpt4 key购买 nike

我使用 git up为了避免merge bubbles ,但有时我会不小心发出 git pull

git up 系统地替换 git pull 的最佳方法是什么?

最佳答案

git-config 中所述文档,不可能给现有的 git 命令起别名。

我们可以使用一个 bash 函数,它会要求您确认是否要实际使用 git pull 命令,并且还为您提供了使用 git up 的机会:

function git() {
if [[ $@ == "pull" ]]; then
read -p "Do you want to [p]ull, [u]p or [a]bort? " yn
case $yn in
[Pp]* ) command git pull;;
[Uu]* ) command git up;;
* ) echo "bye";;
esac
else
command git "$@"
fi
}

例子

$ git pull
Do you want to [p]ull, [u]p or [a]bort? u
Fetching origin
master up to date
$ git pull
Do you want to [p]ull, [u]p or [a]bort? p
Already up-to-date.
$ git pull
Do you want to [p]ull, [u]p or [a]bort? a
bye

关于git - 用 git up 替换 git pull,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31400298/

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