Skip to content

Instantly share code, notes, and snippets.

@theodorosploumis
Last active November 18, 2015 22:35
Show Gist options
  • Save theodorosploumis/b5fb02533bc7da373ec0 to your computer and use it in GitHub Desktop.
Save theodorosploumis/b5fb02533bc7da373ec0 to your computer and use it in GitHub Desktop.
Install Git on Shared hosting (Tested with Freebsd)
#!/bin/bash -e
# IMPORTANT. You must have gcc and wget installed
echo -n "Please enter the Git branch (eg 2.6.2): "
read branch
echo -n "Perl path (run 'which perl' to find the path): "
read perl_path
# Add bin in PATH
echo "Adding ~/bin into PATH"
echo "export PATH=\$HOME/bin:\$PATH" > ~/.bash_profile
source ~/.bash_profile
# Create ~/src folder if not exist
echo "Creating ~/src folder if not exist"
mkdir ~/src
cd src
# Download git files from source
echo "Downloading Git files from Github"
wget http://github.com/git/git/archive/v${branch}.tar.gz --no-check-certificate
tar -xvf v${branch}.tar.gz
rm v${branch}.tar.gz
# Create ~/git-folder folder if not exist
echo "Creating git folder if not exist"
mkdir ~/git-folder
# Compile from source
echo "Compiling source"
cd ~/src/git-${branch}
autoconf
./configure --prefix=$HOME/git-folder --with-curl --with-expat --enable-pthreads=-pthread --without-conv
gmake PERL_PATH="${perl_path}"
gmake install PERL_PATH="${perl_path}"
# Add git alias command
echo "Adding git alias"
echo 'alias git="~/git-folder/bin/git"' > ~/.bash_profile
source ~/.bash_profile
# Exit
echo "Git installation finished! Run git to test it."
@theodorosploumis
Copy link
Author

ToDo:

  • Option for "git-folder" path.

@theodorosploumis
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment