push to remote repository on local NAS fails

I am uisng sourcetree 1.8.3.0 on Win10. I have created a GIT repository on a local NAS as a file set. Then clone this to local workspace on my C drive. Update the content on local repsository C drive ... commit .... then push back to the repository on ther NAS. I get the following error ...

"git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin master:master

Pushing to O:\GIT\GV-TDMA\PSU-IO Board\EaglePCB

 

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."

      

If I do the same process but using Bitbucket to host the remote repository it all works OK  ....

Whats wrong .... ????

 

Any help appreciated

 

 

 

 

1 answer

Your NAS isn't really setup as a real git server.

To get rid of this error go to the folder on the NAS and run this command in terminal:

git config receive.denyCurrentBranch ignore

Now you can push to the file server without seeing that message.

It is best to have the repo on the NAS as a "bare" repo.
(http://www.saintsjd.com/2011/01/what-is-a-bare-git-repository/)

If you don't you'll have this other annoying problem if you open your NAS repo in SourceTree:

The “old” files on the server will be seen as “different” from the “latest” commit that you pushed to it. So it will think the “old” files are “new changes” that need to be commiteed. But they aren’t.

So what you have to then do is double click the latest commit in the history view and select discard changes. (remember the changes aren’t actually changes, they are the old files which are different because they are old.)

Doing that will make the contents of the folder match the latest branch with the exception of any files that were deleted in the latest commit. Those files will remain and will show up as untracked. Just delete them manually.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

847 views 3 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you