git-upload-pack: command not found

后端 未结 5 755
孤城傲影
孤城傲影 2020-12-25 13:19

I\'ve read this answer about eight-five times, but there\'s something I\'m not understanding correctly:

git-upload-pack: command not found, how to fix this correctly

相关标签:
5条回答
  • 2020-12-25 13:23

    Yes, it is to do with login and non-login shells. The .bashrc file only gets loaded in non-login shells. You can use .bash_profile for login shells. Just add the same modification to your PATH in the .bash_profile file and you should be good.

    export PATH=/usr/local/bin:$PATH
    

    You may find this is an interesting article on the difference between .bashrc and .bash_profile, and login and non-login shells.

    0 讨论(0)
  • 2020-12-25 13:35

    I was getting the following errors: git-credential-osxkeychain died of signal 11 When I was doing git pull, I would get fatal: https://github.com/.../../info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?

    I am guessing it had to do with my previous invalid github credentials in the keychain.

    • Opened keychain access tool using Command space
    • searched for github in the keychain access tool
    • removed all the entries related to github (since I no longer needed it)
    • followed the setup git password caching section again setup git
    • it worked

    Incase any of the above answers does not help.

    0 讨论(0)
  • 2020-12-25 13:39

    My solution for this problem

    1. Check path for the git-upload-pack on your remote machine:

      ssh yourname@IP-addressORdomain 'which git-upload-pack'
      

    If it gives a path - copy it (without git-upload-pack and trailing slash. Examples: /usr/bin, /home/yourname/bin, /whatever/gituploadpack/path, etc.).

    1. Check your PATH on the remote machine during login shell:

      ssh yourname@IP-addressORdomain 'echo $PATH'
      

    There is no such a path (/whatever/gituploadpack/path), is not it? Good!

    1. Login to your remote machine:

      ssh yourname@IP-addressORdomain
      
    2. Open .bashrc_profile:

      nano /home/yourname/.bashrc_profile
      
    3. Find these lines if any:

      if [ -f ~/.bashrc ]; then
           ~/.bashrc
      fi
      

    ...and change them for:

        if [ -f ~/.bashrc ]; then
            source ~/.bashrc
        fi
    
    1. Open .bashrc:

      nano /home/yourname/.bashrc
      
    2. Add these 4 lines:

      if [ -d "/whatever/gituploadpack/path" ] ; then
        PATH="$PATH:/whatever/gituploadpack/path"
      fi
      export PATH
      
    3. Exit the remote machine:

      exit
      
    4. Check your PATH on the remote machine during login shell:

      ssh yourname@IP-addressORdomain 'echo $PATH'
      

    Do you see /whatever/gituploadpack/path? Congrats!

    Note now you've solved not only git-upload-pack problem but also git-receive-pack and other executables on your /whatever/gituploadpack/path!

    0 讨论(0)
  • 2020-12-25 13:40

    I solved this issue in my case by logging into the remote machine, a Ubuntu box, and doing sudo apt-get install git. Not sure if this is overkill or not, but solved the problem for me instantly.

    0 讨论(0)
  • 2020-12-25 13:44

    This is connected to this issue:

    https://serverfault.com/questions/130834/svnssh-getting-bash-to-load-my-path-over-ssh

    Ssh is not loading your environment by default when sending a command without going to interactive mode.

    good solution is the one with .ssh/environment file:

    in /etc/ssh/sshd_config add:

    PermitUserEnvironment yes
    

    Then just create .ssh/ directory and dump envronment to .ssh/enviroment:

    cd ~/
    mkdir .ssh
    env > .ssh/environment
    

    Restart SSH

    /etc/init.d/sshd restart
    

    Now when you do this from your local machine:

    ssh you@server.com  "which git-upload-pack"
    

    you s'd get

    /usr/local/bin/git-upload-pack
    

    and git clone s'd work.

    0 讨论(0)
提交回复
热议问题