Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

push to remote repository on local NAS fails

motyalcrab July 5, 2016

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

0 votes
thinsoldier
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2016

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
TAGS
AUG Leaders

Atlassian Community Events