Git Need advice on setting up (remote and local repo)

I bought a personal dev block that I will use to deploy the material that I create on my laptop. I thought it would be nice to use Git for code management. The idea was that I would continue to do on my laptop and, when necessary, would make changes to the remote dev block.

  • I initialized the git repo to the field and
  • cloned it on my laptop.
  • But after doing git push I get this error:

    remote: error: refusal to update the verified branch: refs / heads / master remote: error: by default, updating the current branch in a non-bare repository remote: error: is denied because this will lead to an inconsistency between the index and the remote: error tree of work that you clicked and would require "git reset --hard" to match

I know that the remote repo was not open.

I want to ask if the only way can go with my setup:

  • Initialize bare repo on server
  • Clone it on my laptop.
  • add new files to the local laptop repository and commit files
  • click on relay remote dev.

Even this setup gives me errors:

 No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'. fatal: The remote end hung up unexpectedly 

EDIT

I tried

 git push origin master 

Received this error:

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

Oh dumb to me ... I think it's sudo , as in

sudo make me intelligent

+7
git installation
source share
2 answers

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

The second message was caused by the fact that you just created a repo created. When you cloned the repo and checked the working copy, he created a master branch for you. However, when you tried to push, there was no main branch on the remote repo, so it complains.

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

+10
source share

The second problem:

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

displayed when wrong file owners and permissions . This message means that in the current workin repo that you are trying to click, some files cannot be written. Take a look all the way to .git/refs/remotes/origin/master to determine the problem. I would recommend not sudo with git , because it will create files, etc. as the root of the unix user and will not allow anyone else to work with this repo without sudong all the time.

If you are in a multi-user environment, you can create a new user git with an empty password (without ssh for this user!), With which you can switch using su git (su = switch user), which handles all pushing / fetching / cloning, etc. .d. This is essentially the same as the de-monitored configuration (one user for any metafiles), but may have some advantages in some circumstances.

0
source share

All Articles