Installing Git with non-root user account

前端 未结 6 1523
名媛妹妹
名媛妹妹 2020-12-12 20:37

I\'ve already set up a Git repository on GitHub and committed a few changes from my Windows machine.

But tomorrow I\'ll have to work in this repository from a machin

相关标签:
6条回答
  • 2020-12-12 21:03

    To install git and dependencies from source the following maybe useful.

    Replace with the location you are installing your non-root apps and consider checking for latest versions of source code.

    wget https://curl.haxx.se/download/curl-7.47.1.tar.gz
    tar -xf curl-7.47.1.tar.gz
    mkdir <local_curl_dir>
    cd curl-7.47.1
    ./configure --prefix=<local_curl_dir>
    make
    make install
    
    wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz
    tar -xf expat-2.1.0.tar.gz
    mkdir <local_expat_dir>
    cd expat-2.1.0
    ./configure --prefix=<local_expat_dir>
    make
    make install
    
    wget https://github.com/git/git/archive/v2.6.4.tar.gz
    tar -xf v2.6.4
    mkdir <local_git_dir>
    cd git-2.6.4
    make configure
    ./configure --prefix=<local_git_dir>/git --with-curl=<local_curl_dir>/curl --with-expat=<local_expat_dir>/expat
    make
    make install
    
    0 讨论(0)
  • 2020-12-12 21:07

    A related answer is https://askubuntu.com/a/350.

    I could get it work with the third method proposed:

    apt-get source git
    cd git_vXXX
    ./configure --prefix=$HOME
    make
    make install
    

    I don't know why, but when I had tried to install from the source download from github instead, I had a lot of problems with missing dependencies

    0 讨论(0)
  • 2020-12-12 21:15

    This is what I ended up doing, the main trick being the make flags:

    wget -O git.tar.gz https://github.com/git/git/archive/v2.17.0.tar.gz
    tar zxf git.tar.gz
    mv git-2.17.0 git
    cd git
    make configure
    ./configure --prefix=`pwd` --with-curl --with-expat
    # ./configure --prefix=`pwd`
    # Make flags from https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA@mail.gmail.com/
    make NO_GETTEXT=Nope NO_TCLTK=Nope
    make install NO_GETTEXT=Nope NO_TCLTK=Nope
    

    Credits:

    1. 79E09796's answer above was a good tip, but didn't work for my case on Cloudways and did not require compiling curl and expat.

    2. A random email record I found on the internet: https://public-inbox.org/git/CAP8UFD2gKTourXUdB_9_FZ3AEECTDc1Fx1NFKzeaTZDWHC3jxA@mail.gmail.com/

    0 讨论(0)
  • 2020-12-12 21:20

    You can download the git source and do ./configure --prefix=/home/user/myroot && make && make install to install git to your home directory provided you have the build tools. If you don't have the build-essential package installed (dpkg --list|grep build-essential), you will need to install those to your home directory as well.

    0 讨论(0)
  • 2020-12-12 21:22

    I don't like link-only answers, but this link I followed step-by-step on a Fedora machine and it worked without modification. Very, very easy. The binaries end up in your ~/bin directory. You download a tarball, extract the sources, run make and run make install and that is it.

    As the author states, the 2 prerequisites are gcc and ssh and if you meet these git should work for you as a non-root user.

    0 讨论(0)
  • 2020-12-12 21:23

    for the latest version(which i mean git-2.25.0-rc1 or upper), you need to

    wget https://github.com/git/git/releases/tag/v2.25.0-rc1 -O git.zip 
    unzip git.zip 
    cd git-2.25.0-rc1 
    export PATH=`pwd`:$PATH
    

    and of course, you can add the last line into your .bashrc or .zshrc or something else for more convenience.

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