Git init –bare – Not Working on working tree

I am following the examples here
http://wiki.dreamhost.com/Git

Basically I want to create a git repo i can push to on a server from my desktop…
On host:

  • How to list only version tags with git-log?
  • Git failing to ignore .DS_Store defined in global ignore
  • git describe fails with “fatal: No names found, cannot describe anything.”
  • Git: How to Undo commit *and* revert to last branch
  • How would Git handle a SHA-1 collision on a blob?
  • git doesn't auto commit when I pull
  • [host ~]$ mkdir project.git
    [host ~]$ cd project.git
    [host project.git]$ git init --bare
    [host project.git]$ exit
    

    Then locally:

    [local ~]$ cd project
    [local project]$ git init
    [local project]$ touch .gitignore
    [local project]$ git add .
    [local project]$ git commit
    

    On host if i CD into the directory.. I am shown the following files (which usually sit in the .git dir)

    HEAD  branches  config  description  hooks  info  objects  refs
    

    On local I then create a remote push:
    git remote add origin ssh://XXX@XXX/home/XXX/XXX/
    It pushes says it has worked…

    Counting objects: 3, done.
    Writing objects: 100% (3/3), 210 bytes, done.
    Total 3 (delta 0), reused 0 (delta 0)
    

    However when I go back to the working folder on the server, there is nothing there.. it is just the .git files listed above.

    I have done this before and it worked this way… just this time I must be doing something wrong.

    UPDATE

    If I try to create the repo on the server without –bare … then I get this error on push

    remote: error: refusing to update checked out branch: refs/heads/master
    remote: error: By default, updating the current branch in a non-bare repository
    remote: error: is denied, because it will make the index and work tree inconsistent
    remote: error: with what you pushed, and will require 'git reset --hard' to match
    remote: error: the work tree to HEAD.
    remote: error: 
    remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
    remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
    remote: error: its current branch; however, this is not recommended unless you
    remote: error: arranged to update its work tree to match what you pushed in some
    remote: error: other way.
    remote: error: 
    remote: error: To squelch this message and still keep the default behaviour, set
    remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
    

    UPDATE AND RESOLUTION….

    I found this which works really well
    http://toroid.org/ams/git-website-howto

    Essentially use a –bare then have hook which copies your latest commit to a working directory!

  • git repository ignoring all .dlls
  • Run `git log` on a remote branch
  • Android adding custom lint rule to the project (git)
  • EGIT does not add origin github remote
  • How to only get the name of files which changes are more than whitespaces?
  • Single Git repo with directories in multiple locations
  • 2 Solutions collect form web for “Git init –bare – Not Working on working tree”

    git init --bare creates a “bare” repository – one that does not have a working directory associated with it. What you are seeing is what is expected. If you want a separate repository that has a checked out working directory associated with it, don’t use the --bare option, but note that doing so has additional implications, because git push acts differently when the remote is not a bare repository, in order to protect you from losing any unstaged/uncommitted changes you may have in the remote.

    What you see seems correct. The .git files you see in that folder (and a lot of it in the objects directory) contains all your git repository.

    When you make a “bare” repository, this prevents anybody else to edit the files directly there (on your host machine), not having the project checked out with all your source file is one of the thing that would prevent such editing.

    Git Baby is a git and github fan, let's start git clone.