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 7991023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:10:33+00:00 2026-06-04T13:10:33+00:00

I have a Git submodule that I have successfully cloned in to my main

  • 0

I have a Git submodule that I have successfully cloned in to my main project. However, when I make changes in the submodule and try to push them back to the original submodule repository, Git refuses to do it. Why, and how can I fix this?

Example: I have project sub and project super in two separate folders. I included sub as a submodule under super. I make changes in folder super/sub, then try to push these changes to the original project sub. Git complains.

EDIT: Regarding the error message, I’m using Git Bash on Windows and unfortunately cannot get the exact error message copied out of the terminal. Here’s the most pertinent lines:

remote: error: refusing to update checked out branch: refs/heads/master. By default, updating the current branch in a non-bare repository is denied, because it will make the index and work tree inconsistent with what you pushed, and will require ‘git reset –hard’ to match the work tree to HEAD.

Note: Both repositories live on my hard drive.

  • 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-06-04T13:10:34+00:00Added an answer on June 4, 2026 at 1:10 pm

    This has nothing to do with the repo being a submodule.

    You are pushing to a git repo with a working copy (a non-bare repo), and are trying to push to the same branch that is currently checked out – by default git doesn’t let you do that.

    Before continuing you should ask yourself if you really want to do that. That’s similar to, let’s say you cloning a colleagues repo directly and then trying to push to it. If you succeeded, it’s possible that you could cause your colleague to loose work if they had uncommitted changes, or local files which when updated will be overwritten with tracked files.

    Easy solution

    The easiest solution is to not push at all and just pull from your other repo instead. The end result is the same, but since your’re pulling updates in (and that’s simply normal) git won’t say anything about that.

    Slightly less-easy solution

    You can push into your other working copy, if you change the receiving repo’s git config (read the rest of the error message) to allow it to be pushed into. To do that, in the receiving repo:

    git config receive.denyCurrentBranch ignore
    

    More details about that are in the help (git config --help)

    receive.denyCurrentBranch
        If set to true or "refuse", git-receive-pack will deny a ref update to the
        currently checked out branch of a non-bare repository. Such a push is potentially
        dangerous because it brings the HEAD out of sync with the index and working tree.
        If set to "warn", print a warning of such a push to stderr, but allow the push to
        proceed. If set to false or "ignore", allow such pushes with no message. Defaults
        to "refuse".
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple project that has one submodule. $ git submodule 964737623a362f6303e87ec41f2c7090c8c2c093 lib/mongodb-php-odm
I have git projects that share a common library as a git submodule. When
I have a project that has a submodule at lib/three20 My .gitmodule file looks
Suppose we have the following repository structure on github: company:project.git \- company:submodule.git A developer
I have a project which have a git submodule the project is hosted in
I have a project in Git that has several submodules, and I need those
I have one Git repository that contains a git submodule. In Xcode 4.2.1 I
I have two git repositories: report.git (Master on remote location) cloned.git (Local) I lost
Is it possible to have a subversion repository as a submodule in git? In
I have a git repo and I want to add a submodule to it.

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.