Installing Git on your server

Try Fast Read
0
0



First things first, If you do not know what is GIT… you are missing one of the best revision control system on the internet. It can handle all types of your work, be it programming, designing, or any casual work. Git was initially designed and developed by Linus Torvalds for Linux kernel development in 2005, and has since become the most widely adopted version control system for software development. You do have https://github.com where you can create public repo or private repo (for a small fee). But if you have your own server/computer, why not have git on your own system?

Install git in your system
(Download the exe in windows, dmg in mac,
for linux

Ubuntu: sudo apt-get install git-core
Fedora: sudo yum install git
Arch: sudo pacman -S git

Then create the following script in your favorite text editor with extension “.sh”,for example smjrifle-git.sh

if [ "$#" -eq 1 ]
then
sudo mkdir $1
cd $1
sudo git init --bare
cd ..
sudo chown git:git $1 -R
sudo chmod 775 -R $1
echo "Created git repo for $1"
echo "You can clone the repo using git clone git@smjrifle.net:$1"
echo "or you can add your codes to repo using git remote add origin git@smjrifle.net:$1"
else
echo "Please pass the filename"
fi

and run it in your gitbash/terminal via

sh smjrifle-git.sh gitdirname

If you get a permission error, you can run

sudo chmod a+w smjrifle-git.sh

the cloning or add repo url is of format

git_username@your_ip_or_domain:path_to_file

You can learn about adhoc sharing of git repo from here

Post navigation