gpt4 book ai didi

git - 你怎么能只 pull 当前分支?

转载 作者:IT王子 更新时间:2023-10-29 00:34:52 26 4
gpt4 key购买 nike

是否有一种配置方法可以在不指定分支的情况下进行设置?

最佳答案

Git 已经只 pull 当前分支。如果您将分支设置为跟踪分支,则无需指定远程分支。 git branch --set-upstream localbranch reponame/remotebranch 将建立跟踪关系。然后你发出 git pull [--rebase] 并且只有那个分支会被更新。

当然,所有远程跟踪分支和远程的所有引用都会更新,但只会修改您的本地跟踪分支。

有用的 Bash 别名可以减少这种常见操作的输入:

# Add an alias to pulling latest git changes into your same branch
alias pullhead='git pull origin $(git rev-parse --abbrev-ref HEAD)'

执行相同操作的 Powershell 函数:

Function pullhead {
$cur_head="$(git rev-parse --abbrev-ref HEAD)"
& git pull origin ${cur_head}
}

关于git - 你怎么能只 pull 当前分支?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6052005/

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