0

WHAT I AM TRYING TO ACHIEVE---

I know little about git and trying to learn it. I don't have git installed in my server.

Hence I am trying to create a folder(Git Repos Folder) in my system that will act as a directory of repositories. (Like repositories created in GitHub) and another folder(Git Clones Folder) where I can clone the repos and work on them.( Like local clones of github repositories).

I want to be able to commit and push from any of the repositories in Git Clones Folder to the respective repositories in Git Repos Folder.

WHAT I HAVE TRIED -

I created a repo named praveenpuglia.com inside Git Repos Folder and ran git init to make it a git repository.

Next I cloned the repo as praveenpuglia.com inside Git Clones Folder using git clone D:/Git Repos Folder/praveenpuglia.com

I put a readme file , staged and committed it.

When I try to push the changes to the master, I get these errors

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

What am I doing wrong and how do I set it up? I have tried few of the available answers here but could not understand.

1

1 Answer 1

1

If you want to push to the remote repository it must be created as bare repository. You can convert remote repository to bare by:

git config --bool core.bare true
9
  • I did that and pushed from the clone. It got pushed. however the pushed file is not reflected in the D:/Git Repos Folder/praveenpuglia.com folder. Feb 23, 2014 at 15:38
  • Try to check 'git log' on your remote repository. Do you see all your commits ?
    – ceth
    Feb 23, 2014 at 15:39
  • log shows the commit although it does not show the readme file. Author: Praveen Puglia <[email protected]> Date: Sun Feb 23 20:38:48 2014 +0530 Initial Commit. Readme added. Feb 23, 2014 at 15:44
  • It is correct behaviour for the bare repository. You can try to clone another copy of your remote repository and check that your readme file present on clone repository.
    – ceth
    Feb 23, 2014 at 15:49
  • Great. So the new one has the readme but I am still confused as to what's the role of a bare repo then? Would love some education on it. Feb 23, 2014 at 15:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.