【发布时间】:2020-01-08 00:49:38
【问题描述】:
我的目标是在笔记本电脑上编写代码,然后推送到 SSH 远程,在那里我可以运行计算量更大的脚本。
[my_laptop]$ git remote -v
my_remote ssh://username@server.com:/home/username/projects/my_project (fetch)
my_remote ssh://username@server.com:/home/username/projects/my_project (push)
origin git@github.com:username/my_project.git (fetch)
origin git@github.com:username/my_project.git (push)
SSH 远程预装了 git 1.7.1 (CentOS),但我想将 git config 选项 receive.denyCurrentBranch 设置为 updateInstead,这是在 git 2.3.0 中引入的。
我从远程服务器上的源代码安装了 git 2.9.5 并设置了一个别名 git=/home/username/bin/git2,我可以将其验证为使用 git 2.9.5。
[server]$ which git
alias git='git2'
~/bin/git2
[server]$ git --version
git version 2.9.5
但是,当我尝试从笔记本电脑推送到遥控器时,我收到“错误的配置值”错误:
[my_laptop]$ git push my_remote my_branch
fatal: bad config value for 'receive.denycurrentbranch' in ./config
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我相信这是因为我的git push 是用 git 1.7.1 而不是 2.9.5 接收的。
[my_laptop]$ ssh -t username@server.com "git --version"
git version 1.7.1
Connection to server.com closed.
[my_laptop]$ ssh -t username@server.com "git2 --version"
git version 2.9.5
Connection to server.com closed.
如何在 SSH 服务器上设置“默认”版本的 git 以使用 2.9.5 而不是 1.7.1?我在服务器上没有管理员权限。
【问题讨论】: