my-env/install/git
2022-12-11 14:32:18 +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 "${HOME}/install/git" && \
git pull
else
git clone https://github.com/git/git.git --depth=1 "${HOME}/install/git" && \
cd "${HOME}/install/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 -oq /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