git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git 2 force commits but Git 1 doesn't

From
MWMichael Ward <mward@smartsoftwareinc.com>
Date
Jun 22, 2020, 19:40 UTC
Message-ID
<dea24348-770c-1228-115d-23153fbecebd@smartsoftwareinc.com>

We have some repositories we are hosting here using Apache's DAV module to handle remote connections.

The repositories are created using the following:

mkdir [reponame].git cd [reponame].git git --bare init git update-server-info

Our Apache location directive is as follows:
<Location /[reponame].git>
         DAV on
         AuthType Basic
         AuthName "Git"
         AuthBasicProvider ldap
         AuthLDAPUrl [ldap server info]
         <RequireAny>
                 require [ldap filter]
         </RequireAny>
</Location>

The repository config generates with the values in the core section below, and we add the receive and advice sections:

[core]
         repositoryformatversion = 0
         filemode = true
         bare = true
[receive]
         denyNonFastForwards = true
         denyDeletes = true
[advice]
         pushFetchFirst = true

The odd behavior comes when we have git 1 vs git 2 clients attempting to push in changes on the same branch. Git 1 clients will prompt the user that they are out of date and need to pull. Git 2 clients don't and will force push and overwrite the head revision. This occurs with either Git 1 or Git 2 on the server.

We've tested this with the latest Git 2 client on Fedora 32 and Git 1 client on CentOS 7.8. The other oddity is that even when the Git 2 client does a pull to receive changes before making changes and pushing, when another user pulls the change, there is a message shown that a commit was forced.

What am I missing in the repository settings to prevent forced pushes from working and force users to pull before being able to push?

Thanks!
Michael Ward
Next: brian m. carlson
Message 1 of 19 in “Git 2 force commits but Git 1 doesn't”
  1. Michael WardJun 22, 2020
  2. brian m. carlsonJun 22, 2020
  3. Michael WardJun 22, 2020
  4. Michael WardJun 22, 2020
  5. brian m. carlsonJun 22, 2020
  6. Michael WardJun 22, 2020
  7. brian m. carlsonJun 22, 2020
  8. Michael WardJun 22, 2020
  9. brian m. carlsonJun 23, 2020
  10. René ScharfeJun 23, 2020
  11. brian m. carlsonJun 23, 2020
  12. René ScharfeJun 23, 2020
  13. brian m. carlsonJun 23, 2020
  14. René ScharfeJun 24, 2020
  15. http-push: ensure unforced pushes fail when data would be lostbrian m. carlson, Jun 23, 2020
  16. Eric SunshineJun 23, 2020
  17. brian m. carlsonJun 23, 2020
  18. http-push: ensure unforced pushes fail when data would be lostbrian m. carlson, Jun 23, 2020
  19. Junio C HamanoJun 23, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.