my-env/install/git
2022-07-05 17:05:34 +08:00

41 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
##makedesc: Install git (latest)
echo
echo "==============================================="
echo "Installing git (latest)..."
echo "==============================================="
echo
installed() {
command -v "$1" >/dev/null 2>&1
}
! installed make && sudo apt install -y make
if installed git; then
if [ -d "${HOME}/install/git" ]; then
cd /usr/src/git/ && \
git pull
else
git clone https://github.com/git/git.git --depth=1 "${HOME}/install/git" && \
cd /usr/src/git/
fi
sudo make prefix=/usr/local all && \
sudo make prefix=/usr/local install
else
! installed wget && sudo apt install -y wget
[ -d "${HOME}/install/git" ] || mkdir -p "${HOME}/install/git"
wget https://github.com/git/git/archive/master.zip -O /tmp/git.zip && \
unzip -q /tmp/git.zip -d "${HOME}/install/git" && \
rm /tmp/git.zip && \
cd "${HOME}/install/git/git-master" && \
sudo make prefix=/usr/local all && \
sudo make prefix=/usr/local install && \
cd - && \
rm -rf git && \
git clone https://github.com/git/git.git --depth=1 "${HOME}/install/git"
fi
git --version