Overkill workaround
Install Anaconda as a user and install git with conda.
Advantages
Anaconda can be installed as user, and a conda environment can be created which can help you to install other packages. This way you don't need to compile git from source, nor you need to install libcurl and perl, so you won't get the error
git: 'remote-https' is not a git command. See 'git --help'
after successfully compiling git.
Steps to install Anaconda, then git
- read the Anaconda installation manual which points to the download page's shell script file.
- Download the script file:
- copy to your local machine and then copy with scp (e.g. winscp) to the Linux machine or
- use a terminal on the Linux machine and issue
wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh
.
- add executable rights to yourself on the file by issuing
chmod +x Anaconda3-2020.11-Linux-x86_64.sh
- follow the installation instructions where you can also specify into which folder you want to install anaconda
- after installation, chose one of the possibilities below to successfully invoke git later:
- you either activate a conda environment, which is useful e.g. if you need to create different conda environments (it is common if you work with python). To activate an environment, you need to ask the installer (at the end of the installation) to add the conda initialization code into your
~/.bashrc
file [see below]. Using this method, your path won't be polluted, and you will see if conda-related binaries are also in your current path. Or you can
- add the installed bin's folder to your path, e.g. if you installed anaconda into
/home/myusername/anaconda3
, it will be in /home/myusername/anaconda3/bin
. Your new executable file conda
will be also there which will help you to install packages like git, python or pandoc, or
- cd into the binary folder of anaconda, e.g.
cd /home/myusername/anaconda3/bin
, and execute the commands below.
- don't forget to take into effect the new settings by, e.g., closing and opening the terminal again if you selected method 1. or 2. in point 5. If you selected 1, you will see something like
(base) myusername@servername
indicating you are using the base conda environment.
- Now you can install git using conda by issuing
conda install -c anaconda git
.
Your .bashrc
will contain likes like this if you told the Anaconda installer to initialize conda for you:
# content of your .bashrc in your home dir
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/myusername/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/myusername/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/myusername/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/home/myusername/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
sudo apt-get install git
).