Git Setup (remote and local repo) advice needed Git Setup (remote and local repo) advice needed git git

Git Setup (remote and local repo) advice needed


The first message, as you said, was because the remote was not a bare repo.

The second message was because the bare repo you created had no branches to begin with. When you cloned the repo and checked out a working copy, it created the master branch for you. When you tried to push however, there was no master branch on the remote repo, so it complains.

Try using git push origin master (or whatever your remote is called) and it should create the branches on the remote for you.


The second issue:

error: unable to create directory for .git/refs/remotes/origin/mastererror: Cannot lock the ref 'refs/remotes/origin/master'.

shows up when your file ownerships and permissions are wrong. This message means that in the current workin repo you are trying to push from some files are not writeable. Take a look at the whole path down to .git/refs/remotes/origin/master to spot the issue. I would recommend to not sudo with git because this will create files etc. as unix user root and prevent anybody else to later work with this repo without sudo'ing all the time.

If you find yourself in a multi-user environement, you might create a new user git with empty password (no ssh for that user!) that can be switched to with su git (su = switch user) which handles all the pushing/fetching/cloning etc. This is essentially what a deamonized setup would also do (one user for any meta files) but might have some advantages in some circumstances.