git-upload-pack : 원격 Git 저장소를 복제 할 때 명령을 찾을 수 없습니다
git을 사용하여 프로젝트의 두 복사본을 동기화 상태로 유지했습니다. 하나는 로컬 상자이고 다른 하나는 테스트 서버입니다. 이것은 ssh를 사용하여 원격 개발 서버에 로그온 할 때 발생하는 문제입니다.
git clone me@me.mydevbox.com:/home/chris/myproject
Initialized empty Git repository in /tmp/myproject/.git/
Password:
bash: git-upload-pack: command not found
fatal: The remote end hung up unexpectedly
fetch-pack from 'me@me.mydevbox.com:/home/chris/myproject' failed.
(유죄를 보호하기 위해 파일 이름이 변경되었습니다 ...!)
두 상자 모두 Solaris 10 AMD를 실행합니다. --upload-pack=$(which git-upload-pack)
명령이 작동 $PATH
하고 RTFM 솔루션에 따라 'git-upload-pack'에 대한 경로 가 포함되어 있음을 증명 하면 약간의 파고를 수행 했지만 실제로는 성가 시며 'git push'가 작동하지 않습니다. --unpack=
옵션 이 없다고 생각하기 때문입니다 .
또한 모든 git 명령은 로컬 상자에서 제대로 작동하며 동일한 NFS 마운트에 설치된 동일한 버전의 소프트웨어 (1.5.4.2) /usr/local/bin
입니다.
아무도 도와 줄 수 있습니까?
git-upload-pack
비 로그인 쉘의 경로에 있는지 확인하십시오 . (내 컴퓨터에서는에 있습니다 /usr/bin
).
비 로그인 쉘에서 원격 시스템의 경로를 확인하려면 다음을 시도하십시오.
ssh you@remotemachine echo \$PATH
Bash, Zsh 및 tcsh 및 다른 쉘에서도 작동합니다.
제공하는 경로에가있는 디렉토리가 포함되어 있지 않으면 (Bash), (Zsh), (tcsh) 또는 쉘에 해당 하는 디렉토리 git-upload-pack
로 설정하여 수정해야합니다 ..bashrc
.zshenv
.cshrc
원격 시스템에서이 변경을 수행해야합니다.
remote에 추가해야 할 경로가 확실하지 않은 경우 다음 PATH
명령을 사용하여 찾을 수 있습니다 (원격 시스템에서이 경로를 실행해야 함).
which git-upload-pack
내 컴퓨터에서 인쇄합니다 /usr/bin/git-upload-pack
. 따라서이 경우 /usr/bin
원격 비 로그인 쉘에 있는지 확인해야합니다 PATH
.
"-u"옵션을 사용하여 경로를 지정할 수도 있습니다. 내 .bashrc가 비 대화 형 세션에서 소스되지 않는 컴퓨터에서 이것이 도움이된다는 것을 알았습니다. 예를 들어
git clone -u /home/you/bin/git-upload-pack you@machine:code
Brian의 답변을 바탕으로 , 복제 후 다음 명령을 실행하여 업로드 팩 경로를 영구적으로 설정할 수 있으므로 --upload-pack
후속 풀 / 페치 요청이 필요하지 않습니다. 마찬가지로 수신 팩을 설정하면 --receive-pack
푸시 요청 이 필요하지 않습니다.
git config remote.origin.uploadpack /path/to/git-upload-pack
git config remote.origin.receivepack /path/to/git-receive-pack
이 두 명령은 다음 행을 repo 's에 추가하는 것과 같습니다 .git/config
.
[remote "origin"]
uploadpack = /path/to/git-upload-pack
receivepack = /path/to/git-receive-pack
자주 사용하는 사용자 clone -u
는 다음 별칭에 관심 이 있을 수 있습니다. myclone은 설명이 필요합니다. myfetch / mypull / mypush는로 대체 등 git push
으로 위에서 설명한대로 구성이 수정되지 않은 저장소에 사용할 수 있습니다 git mypush
.
[alias]
myclone = clone --upload-pack /path/to/git-upload-pack
myfetch = fetch --upload-pack /path/to/git-upload-pack
mypull = pull --upload-pack /path/to/git-upload-pack
mypush = push --receive-pack /path/to/git-receive-pack
이 수정 프로그램을 찾아서 성공적으로 사용했습니다.
# Fix it with symlinks in /usr/bin
$ cd /usr/bin/
$ sudo ln -s /[path/to/git]/bin/git* .
Paul Johnston 에게 감사합니다 .
Mac OS X과 다른 유닉스는 보안상의 이유로 적어도 sshd로 컴파일 된 사용자 경로를 가지고 있으므로 git를 / usr / local / git / {bin, lib, ...}로 설치하는 사람들은 git으로 문제를 일으킬 수 있습니다. 실행 파일이 사전 컴파일 된 경로에 없습니다. 이것을 무시하려면 / etc / sshd_config 변경을 편집하는 것이 좋습니다.
#PermitUserEnvironment no
에
PermitUserEnvironment yes
그런 다음 필요에 따라 ~ / .ssh / environment 파일을 만듭니다. 내 자식 사용자는 ~ / .ssh / environment 파일에 다음이 있습니다.
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin
Note variable expansion does not occur when the ~/.ssh/environment file is read so:
PATH=$PATH:/usr/local/git/bin
will not work.
For bash, it needs to be put into .bashrc not .bash_profile (.bash_profile is also only for login shells).
Matt's solution didn't work for me on OS X, but Paul's did.
The short version from Paul's link is:
Created /usr/local/bin/ssh_session
with the following text:
#!/bin/bash
export SSH_SESSION=1
if [ -z "$SSH_ORIGINAL_COMMAND" ] ; then
export SSH_LOGIN=1
exec login -fp "$USER"
else
export SSH_LOGIN=
[ -r /etc/profile ] && source /etc/profile
[ -r ~/.profile ] && source ~/.profile
eval exec "$SSH_ORIGINAL_COMMAND"
fi
Execute:
chmod +x /usr/local/bin/ssh_session
Add the following to /etc/sshd_config
:
ForceCommand /usr/local/bin/ssh_session
I got these errors with the MsysGit version.
After following all advice I could find here and elsewhere, I ended up:
installing the Cygwin version of Git
on the server (Win XP with Cygwin SSHD), this finally fixed it.
I still use the MsysGit version client side
..in fact, its the only way it works for me, since I get POSIX errors with the Cygwin Git pull from that same sshd server
I suspect some work is still needed this side of Git use.. (ssh+ease of pull/push in Windows)
Like Johan pointed out many times its .bashrc that's needed:
ln -s .bash_profile .bashrc
You must add the
export PATH=/opt/git/bin:$PATH
before this line in the .bashrc:
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
Otherwise all export statements will not be executed (see here).
For zsh you need to put it in this file: ~/.zshenv
For example, on OS X using the git-core package from MacPorts:
$ echo 'export PATH=/opt/local/sbin:/opt/local/bin:$PATH' > ~/.zshenv
I have been having issues connecting to a Gitolite repo using SSH from Windows and it turned out that my problem was PLINK! It kept asking me for a password, but the ssh gitolite@[host] would return the repo list fine.
Check your environment variable: GIT_SSH. If it is set to Plink, then try it without any value ("set GIT_SSH=") and see if that works.
Add the location of your git-upload-pack
to the remote git user's .bashrc file.
My case is on Win 10 with GIT bash and I don't have a GIT under standard location. Instead I have git under /app/local/bin. I used the commands provided by @Garrett but need to change the path to start with double /:
git config remote.origin.uploadpack //path/to/git-upload-pack
git config remote.origin.receivepack //path/to/git-receive-pack
Otherwise the GIT will add your Windows GIT path in front.
'IT story' 카테고리의 다른 글
1… 1이 10.1로 평가되는 이유는 무엇입니까? (0) | 2020.05.26 |
---|---|
배열이 비어 있지 않은지 확인하십시오. (0) | 2020.05.26 |
PowerShell에서 로컬 호스트 이름을 얻으려면 어떻게합니까? (0) | 2020.05.26 |
MYSQL OR 대 IN 성능 (0) | 2020.05.26 |
리눅스에서 터미널 히스토리 삭제하기 (0) | 2020.05.26 |