Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting a git server on localhost

My company does not have a central git server, and neither do they allow me to use BitBucket etc.

Is there anyway I can use my localhost as remote ?

EDIT: I am on a windows machine

like image 857
prometheuspk Avatar asked Dec 02 '13 09:12

prometheuspk


People also ask

Can Git be used locally?

Yes, it is entirely reasonable to use git only locally. You may want to push to a local network drive or removable backup for redundancy reasons, but git itself works perfectly well without connecting to someone else's sever.

Should I run my own Git server?

In cases like these or when you want more control, the best path is to run Git on your own server. Not only do you save costs, you also have more control over your server. In most cases a majority of advanced Linux users already have their own servers and pushing Git on those servers is like 'free as in beer'.


1 Answers

Local directories work just like remote repository URLs, so basically there's nothing you need to do as long as you're the only person using the repository.

Example, assuming Git Bash (from msysgit):

mkdir /c/git
mkdir /c/git/testrepo.git
cd /c/git/testrepo.git
git init --bare
cd $TEMP
git clone /c/git/testrepo.git
cd testrepo
# hackety hack
git add .
git commit -m "I shouldn't be making commits like this but who's gonna sue me"
git push origin master
cd ..
git clone /c/git/testrepo.git testrepo2
cd testrepo2
# wow, all my files are here

That said, just creating a normal local repository with git init gives you a complete Git repository in which you can make commits and everything, and which you can clone and merge/pull from. Most of the time, this is really all you need.

like image 127
Jan Krüger Avatar answered Sep 18 '22 15:09

Jan Krüger