I want to set up an Eclipse project on my Mac and maintain the Git server on my NAS drive. I also want to hook up the Git server to Mobi to take periodic backups.
Basically, when I check in a change on my Mac local drive, I want it to go to the NAS drive.
I see that I need to run git init on my local Mac (Lion) to tell Git that the project is a working Git repository.
But how do I tell it that the Git server is on the NAS drive? And how do I add my initial code into Git? (It keeps telling me no files have been changed)
I have read the Git_book.pdf and some tutorials, but they don’t seem to go back to these fundamentals. I have been using SVN for the past few years, and before that CVS for many moons. Now I am trying to set this up and concurrently grok Git, and having some trouble. (Not using GitHub)
There is no git server. But you may have several remote repositories if you want. Here’s how you do it:
First you set up your development project by creating a git repo using
git init. Then code away and commit changesets to this repo like you would normally do. Now the big difference from SVN here is that when you commit, you commit to the local repo, not some remote repo on another machine.If you want you can pack up this project including repo, move it to another machine and continue like nothing happened. Just tar it up and off you go. However, another and better way of creating a copy of the repo is to clone it into another location. This could be another location on the same machine, or on another machine if you like. You use the
git clonecommand for this.So to set up a bare repo on another machine we can simply do:
This creates a “bare” clone of the repo at this remote location. A bare repo, just means it only contains the repo itself, not a working copy where a revision is checked out.
Now you need to tell your original project that there exists a remote repo too, like this:
Here “origin” is just a name, you can select another one. Now you can
git fetchany changes that may occur at the remote repo into your local repo,git pushchanges that you do in your local repo into the remote repo, and a whole lot of other nice things. You can create as many remote repos as you like, have as many development machines as you like, and cooperate with as many people as you like. They can all have their own repo, and you can sync commits between them as you like.