Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a server to use git?

Tags:

git

If I need to get access to my files on my home computer from work or whatever, do I need to have a network server and check-in the files on there?

If I'm using git, do I still need to have a server or am I actually saving files on their server?

like image 977
jDeveloper Avatar asked Jul 23 '09 16:07

jDeveloper


2 Answers

First, Git is distributed version control system. This means that when working with Git you have full repository at work, and you have also copy of full repository (called clone) at your home computer. You can work at your home computer, comitting changes, reading commit messages, viewing differences, switching branches etc. without need to have constant network access to your computer at work.

Your question then is about how to synchronize repositories at work and at home. There are many possibilities:

  • You can create bare repostory (i.e. without working directory), clone of repository, on some removable media like USB disk (pendrive). You would sync via this repository, pushing to it from one place, and fetching (pulling) from it in other place.

  • You can use one of Git hosting services like mentioned GitHub, and use it to synchronize your repositories. You should remember however that usually free plans require to make your repository public; if you want to have private repository you have to use paid plan (paid service). Check what the site you want to use is offering.

  • You can use git-bundle command: generate bundle on one side using "git bundle" command, then clone/fetch/pull on the other side using bundle file in place of repository URL e.g. git fetch file.bndl. You can transfer bundle in any way, be it on USB flash drive, downloading it via HTTP (plain web server would be enough here), FTP or SCP.

  • You can serve your repository via SSH. For that you need git to have installed both at work and on your home computer, ssh daemon on server (side you are fetching from / pushing to) and ssh client on client. Git doesn't need to be installed globally for all users on server; you can tell git where to find appropriate git binaries via relevant option (see git documentation). In Tips and Tricks page on Git Wiki you would find "How to push/pull via ssh to host behind gateway?" tip.

  • Finally you can serve your repository via HTTP, using simple web server, just like you would publish web pages. You need to remember to run git update-server-info to generate helper information. Usually it is done from post-update hook (and post-commit if repository is non-bare, i.e. if you create commits in it); check out sample hook (and read githooks documentation) to see how it is done.

See also my answer in How can I make my local Git repository available for git-pull? SO question.

like image 101
Jakub Narębski Avatar answered Sep 21 '22 09:09

Jakub Narębski


There are a number of hosted solutions for Git repositories, including GitHub and Unfuddle.

The wording of your question indicates that you might misunderstand what Git (and Distributed Version Control Systems in general) are all about. You might want to read the intro to Git at Unfuddle or an introduction to Git like the one here.

like image 44
mmc Avatar answered Sep 20 '22 09:09

mmc