Xcode 4 git: 'moving' local git project to our remote server

First off, apologies as I'm new to git, ssh and Xcode. Also, I'm a rather command line phobic.

We have a server running where clients connect with ssh authentication pull/push code from/to. It works beautifully from Xcode 4 for existing projects which I had setup using git command line. It's really simple to clone projects from there using Xcode 4 and push commits.

What I'm confused about is how to set our server as the origin/master for local git projects that developers had created with Xcode 4 (with a lot of checkin history). I see there is a hidden .git folder, so I tried:

scp -r .git git@my.server.com:MyProject.git

Then from Xcode 4, I can go ahead and clone it from our server perfectly. I can see the full checkin history. If I try to push changes though, i get a huge error message.

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: 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'. [snip]

I'm at a loss for how to properly do this without losing the precious checkin history that developers already have on their local machines.

Can someone point out the fundamental step or concept I'm missing?

Thanks!

Answers


If you want to push to a repo, it's forbidden by default to push to a branch that is currently checked out.

To avoid this, central repos (those where everyone pushes to) are usually created as bare repos, i.e. they contain only the versioning information and no checked out working copy. These repos are by convention named <repo-name>.git. You can create a bare repo using the --bare flag on git init

git init --bare myrepo.git

But the problem is that you copied a local .git folder to my.server.com instead of creating a bare repo there. In .git/config, there's the information whether the repo is bare or not. In working copies, bare is false, this information is now on the server.

The correct way to get around this would be to

  1. create a bare repo on the server (like written above)
  2. add this repo as a remote in your working copy git remote add origin git@my.server.com:MyProject.git
  3. push the content of your local repo to origin git push --force --all origin

Need Your Help

SyntaxError: Unexpected Identifier in Chrome's Javascript console

javascript google-chrome console

I tested this javascript in Chrome's Javascript console and it returned SyntaxError: Unexpected Identifier.

multiple row insert in Oracle SQL

sql oracle oracle11g

I use multiple row insert syntax in oracle SQL like this: