Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6051899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:52:06+00:00 2026-05-23T07:52:06+00:00

I cloned repository A to repository B using git clone . /somedirectory/b.git . Later

  • 0

I cloned repository A to repository B using git clone . /somedirectory/b.git . Later on, I decided to submodule repository C in B git submodule add /path/to/c.git c_in_b. So how do i push back this addition of submodule to A?

Tried using git push but have the following error

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.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in som
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:52:06+00:00Added an answer on May 23, 2026 at 7:52 am

    This is the genereal behaviour of git, even when submodules are not in the picture. You are pushing to a repo ( A ) which is a “working repository” or “non-bare” and git by default doesn’t allow you to do that and the error message you see shows the reasons and workaround for it.

    In your case, I think you can update the config in A ( set receive.denyCurrentBranch as warn or ignore ) as the error suggest or just checkout another branch on A and then push from B. For long term use, use a bare repo for pushing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I started cloning an SVN repository using the git-svn's clone operation. After about 6
Is there a Python way without using a subprocess to clone a git repository?
I have a git repository which tracks an svn repository. I cloned it using
I am setting up a Git repository. I know you can add repositories using
I have cloned an SVN repository from work using git-svn. During the initial cloning,
I am using git to get my Webkit repository by following this: https://trac.webkit.org/wiki/UsingGitWithWebKit So
I've set up a git repository using gitosis. I've cloned the repository, and I
I got this scenario: I created a Git repository. $ git init Cloned an
I am trying to clone a TFS repository using git-tfs. It works great with
Some repository clones I have allow me to do this: % git pull %

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.