如何将远程 Git 存储库配置为推送、不获取或拉取?
How can a remote Git repository be configured for pushing to, no fetching or pulling?
如何将远程 Git 存储库配置为推送,而不是提取或拉取?
我在一个没有连接到项目管理系统的位置有一个存储库,我想link它到项目经理 (Gogs) 所在的另一个位置。
如何配置本地工作副本只推送到 Gogs 位置,但从不从中提取,即确保 git fetch
或 git pull
从不引用它?
这种遥控器的 .git/config
条目是什么样子的?
你可以设置一个假的抓取URL:
$ git remote set-url origin "https://{pulling-is-disabled-for-this-remote}"
$ # Below command is needed since git remote set-url sets both fetch and push URLs
$ git remote set-url --push origin CORRECT_REMOTE_URL
$ git pull origin
fatal: unable to access 'https://{pulling-is-disabled-for-this-remote}/': Could not resolve host: {pulling-is-disabled-for-this-remote}
因此,此类遥控器的 .git/config
条目如下所示:
[remote "origin"]
url = https://{pulling-is-disabled-for-this-remote}
pushurl = CORRECT-URL-MUST-BE-PUT-HERE
以下 bash 函数将完成这项工作:
git_disable_pull_from_remote()
{
if [ $# -ne 1 ];
then
echo 1>&2 "Usage: git_disable_pull_from_remote <remote_repo>"
return 1
fi
local url="$(git remote get-url --push "")"
git remote set-url "" "https://{pulling-is-disabled-for-this-remote}"
git remote set-url --push "" "$url"
}
示例:
$ git_disable_pull_from_remote origin
如何将远程 Git 存储库配置为推送,而不是提取或拉取?
我在一个没有连接到项目管理系统的位置有一个存储库,我想link它到项目经理 (Gogs) 所在的另一个位置。
如何配置本地工作副本只推送到 Gogs 位置,但从不从中提取,即确保 git fetch
或 git pull
从不引用它?
这种遥控器的 .git/config
条目是什么样子的?
你可以设置一个假的抓取URL:
$ git remote set-url origin "https://{pulling-is-disabled-for-this-remote}"
$ # Below command is needed since git remote set-url sets both fetch and push URLs
$ git remote set-url --push origin CORRECT_REMOTE_URL
$ git pull origin
fatal: unable to access 'https://{pulling-is-disabled-for-this-remote}/': Could not resolve host: {pulling-is-disabled-for-this-remote}
因此,此类遥控器的 .git/config
条目如下所示:
[remote "origin"]
url = https://{pulling-is-disabled-for-this-remote}
pushurl = CORRECT-URL-MUST-BE-PUT-HERE
以下 bash 函数将完成这项工作:
git_disable_pull_from_remote()
{
if [ $# -ne 1 ];
then
echo 1>&2 "Usage: git_disable_pull_from_remote <remote_repo>"
return 1
fi
local url="$(git remote get-url --push "")"
git remote set-url "" "https://{pulling-is-disabled-for-this-remote}"
git remote set-url --push "" "$url"
}
示例:
$ git_disable_pull_from_remote origin