3

I'm a newbie when it comes to git and i went through some video tutorials here

After seeing these tutorials i tried to set up a git repo with my friend using ssh

Note:

  • We are using mac snow leopard
  • The Git version is 1.7.5.4

I managed to set up my code in a folder lets say 'folder1' using

git init

which has my code files .

Then I create an empty repository on my friends machine lets say 'folder2', and I made folder2 a bare repository using

git init --bare --shared

Now I wanted to setup the shared repo as the repository for folder1's code After this, I tried to add the remote on the bare repo using ssh

git remote add origin myFriend@hisIp:/LocationToFile

After this, I pushed the code which gave me a successful message

Now the issue is that the git repo 'folder2' is still show an empty repo (with the folders of an empty repository) and I cant perform git operations in folder2 as even if I do "git status", I get "fatal: This operation must be run in a work tree"

Aatish Molasi
  • 2,138
  • 3
  • 20
  • 43

1 Answers1

11

Since it is a bare repo, it has no working tree. See "What's the -practical- difference between a Bare and non-Bare repository?".

You should clone locally that folder2 repo, in order to execute your commands.

# on server:
cd /path/to/folder2
git clone folder2 folder2b
cd folder2b
git status

Note: It would be best to follow the naming convention for bare repo directory: folder2.git (instead of folder2)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    I had similar issue when I began working from a new session. Found out it was the GIT_DIR variable causing it. Unset solved it. – Rich May 02 '14 at 05:13
  • 1
    @Rich True: I mentioned a similar issue in http://stackoverflow.com/a/6123109/6309 or http://stackoverflow.com/a/17505437/6309 – VonC May 02 '14 at 05:14