gpt4 book ai didi

使用 gitolite 的 git 默认远程分支

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

我正在使用 gitflow一些项目的分支模型。出于这个原因,当有人克隆存储库时,我希望默认 checkout 的分支是 develop 分支而不是 master

对于托管在 Github 上的公共(public)项目,我可以使用该存储库的管理部分来控制它,但是对于使用 gitolite 管理的私有(private)存储库,我发现唯一可行的解​​决方案是通过 ssh 进入托管机器并使用 git update-ref直接在裸存储库中命令。

有什么方法可以远程执行此操作,即无需通过 ssh 连接到远程机器?

最佳答案

在实现 VonC 建议的几个小时后,我遗憾地发现 set-head 脚本 already exists in gitolite repository :-(

但是我已经为此实现了我的版本,所以我将它发布在这里。我实现了一项附加功能,可以将 set-head 命令限制为仅供存储库创建者使用。也许我会 fork gitolite 项目并将该功能添加到原始版本。

顺便说一句,这是我的版本:

#!/bin/sh

. $(dirname $0)/adc.common-functions

[ $# -eq 2 ] || die "usage: $0 <repo> <branch>"

if [ $SDB_WRITER_ALLOWED ]; then
# this will check only for write permission on the given repository
get_rights_and_owner $1 # this also set $repo variable
[ -z "$perm_write" ] && die "You don't have write permission on $repo"
else
# require a repository creator to change default branch
valid_owned_repo $1
fi

# move to repo dir
cd "$GL_REPO_BASE_ABS/$repo.git"

# check for branch existence
match=`git branch | sed 's/^\( \|*\) //' | grep $2`
# this will check for an exact match in branch name
[ "$2" = "$match" ] || die "Unable to find branch $2 in repository $repo"

# update the default checked out branch
git symbolic-ref HEAD refs/heads/$match

echo "Head branch for repository $1 updated to $2"

这是pull request如果有人感兴趣

关于使用 gitolite 的 git 默认远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7091599/

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