7

I currently use svn at work.

Our setup is: everyone has a working copy and we commit to a svn server served by apache2.

So I commit changed, the other update, and everyone can work on the copy as they wish.

So it's pretty easy to deploy.

But now, I'd like to do the same thing but with Git. Would it be possible?

I'd like to have a git repo on my main server, develop at home, commit changes to the server, etc.

Thanks for your help

Tommy B.
  • 3,591
  • 14
  • 61
  • 105

5 Answers5

4

Git - SVN Crash Course

Especially this is of interest for a starter

git init
git add
git clone git://...
git pull
git fetch
git push

Then check the rest of the documentation on the git site

Git documentation

jitter
  • 53,475
  • 11
  • 111
  • 124
3

One thing to add to the other answers:

While a centralized workflow (with one "central" Git repository) is off course possible, you need to keep in mind Git organizes its data differently (as a all, looking into the data content to infer various property, like file rename). See this answer for more differences between Svn and Git.

One consequence is that you should not necessarily consider having just one Git central repository, but several, especially if you have many group of files with different and independent history (they evolve each at their own pace).

SVN can store all those different group in one repository and can branch or tag whatever part it wants (it is just a matter of copying what you need in a "directory" representing a branch or a tag). Git branch and tag at the repository level.

If your set of files is quite coherent, you can have one Git central repo, but if you have several components, may be several "central" Git repos are better.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I think what you mean is that if you have self-contained modules, they can be more easily shared between projects if they are their own git repo. Unlike svn, git cannot clone below the repo level so sharing part of a repo is difficult (but git _can_ make svn-like branches since they're just copies of folders). For a small project, it's probably better to stick with one repo (two repos for 10 files is too much overhead). You can refactor into multiple repos later with tools like [filter-branch](http://stackoverflow.com/questions/6403715). – idbrii Feb 11 '12 at 19:13
  • @pydave: yes, sparse checkout (http://stackoverflow.com/questions/2336580/sparse-checkout-in-git-1-7-0) is hard. No, Git doesn't want to do "svn-like" branches (shudder): branches are first-class citizen with Git, and not directories as in SVN: http://stackoverflow.com/a/5101286/6309 and http://stackoverflow.com/questions/1598759/git-and-mercurial-compare-and-contrast/1599930#1599930 – VonC Feb 11 '12 at 20:19
  • @pydave: yes, you can refactor a Git repo later with `filter-branch`, but Git is much more adapted for a component-based approach anyway (ie, one repo per component): http://stackoverflow.com/questions/6925425/git-strategy-for-a-project-with-many-independent-modules/6926225#6926225 – VonC Feb 11 '12 at 20:21
  • To be clear, I'm not encouraging anyone use svn-style branches. Doing so is madness. – idbrii Feb 11 '12 at 22:08
2

Just set up a centralised repo that everyone pushes to and pulls from.

Just because git has no concept of a central or preferred repo, that doesn't mean you can't designate one to be so by convention among your team.

Abizern
  • 146,289
  • 39
  • 203
  • 257
1

Yes it's possible.

On the server where your stuff is located:

  git init
  git add .

On your local computer:

  git clone git://yourserver/repo localfolder

To get changes:

  git pull
  git fetch

To send changes to server:

  git push

Here are links how to setup your server

Derek Mahar
  • 27,608
  • 43
  • 124
  • 174
Egon
  • 1,705
  • 18
  • 32
  • git://yourserver/repo localfolder But this path, will be served by a normal apache directory listing? – Tommy B. Oct 19 '09 at 15:08
  • see http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#sharing-development – Egon Oct 19 '09 at 15:11
  • Thanks for your answer, but I still don't get it lol. But I found that in the doc you sent me: $ git clone ssh://yourhost/~you/repository So that should do the trick. – Tommy B. Oct 19 '09 at 15:35
  • 1
    You should create a bare repository on the server. – innaM Oct 19 '09 at 19:52
1

Absolutely - you can set up central (bare) GIT repositories that can be used as a central point. Or use something like GitHub.

With GIT it's more a matter of getting your process set up to use it as you wish.

Paddy
  • 33,309
  • 15
  • 79
  • 114