10

I am trying to setup a simple GIT server. I have Ubuntu installed on a Virtual PC (Virtual Box). I installed GIT, created a repo etc

git init 
git add .
git commit "..."

Then on Windows, I did something like below (on cygwin)

git clone [email protected]:proj1

Tried making changes then

git commit -am "..."

but got something like

see image

I suppose I have setup GIT wrong? I read its something to do with bare/non-bare repos? Should I use bare all the time? I tried

git checkout --bare [email protected]:proj1 

but got proj1.git in it, wierd files/folders like (HEAD etc) within. Whats the proper way of setting up GIT?

also can someone explain bare/non-bare repos, I'm kind of lost, with GitHub, there isn't such a thing!

UPDATED 28 Apr 2011 6PM UTC+8

I tried following http://www.youtube.com/watch?v=1gNFrPNF9-Y and on Ubuntu (Server) did

git init --bare

then on Windows (Client/Cygwin) did

git init 
// added readme.txt 
git add .
git commit -m "..."
git remote add origin master [email protected]:proj2
git push origin master

no errors seems ok. But on Ubuntu, I dont see where are my files? I looked at branches/ for 1 theres nth in there?

2 Answers 2

9

A "normal" repository is a directory containing the actual repository, and a working copy. The actual repository is located in a hidden subdirectory with the name .git. The working copy are those files and directories you work with.

A "bare" repository is just the contents of the .git directory, without a working copy.

You can not work on a bare repository. You first have to clone the bare repository to a normal repository, then work on the clone.

In your first attempt you created a "normal" repository. Then you cloned that. Then you tried to push back to the normal repository. Then you got a warning. You should not push to a normal repository. Git warns you when you try to do that. You should only push to a bare repository.

In your second attempt you created a "bare" repository. Then you created a "normal" repository. Then you pushed from the normal to the bare repository. That is (one of) the expected workflow(s). That is why you got no errors or warnings.

When you want to work on your project from the windows machine and from the ubuntu machine then you have two options:

  1. Create a bare repository (doesn't matter where). Then clone from that repository, one on the windows machine and one on the ubuntu machine. Now push from the clones to the bare repository, and pull from the bare repository to the clones. Do not push to the normal repositories.

  2. Create two normal repositories, one on the windows machine and one on the ubuntu machine. Now, when working on ubuntu, you can pull from the windows machine and vice versa. Do not push to each other.

Bottom line: only ever push to bare repositories. In all other cases, when you think you want to push from A to B, instead, go to B then pull from A.

It seems that you are very new to git. Please read one or both of the following very fine books: Git Book, Pro Git.

2
  • 1
    hmm seems like the main learning point is "only ever push to bare repositories. In all other cases, when you think you want to push from A to B, instead, go to B then pull from A". If so, how does GitHub does it? I push to it right (nv used it for awile already ...)?
    – Jiew Meng
    Apr 28, 2011 at 14:12
  • @JiewMeng: GitHub uses bare repositories. The website reads data directly from Git and doesn't need a workdir. May 11, 2012 at 12:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .