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

[Request] Git reset should be able to ignore file permissions

From
ANAlexander Nestorov <alexandernst@gmail.com>
Date
Jun 18, 2013, 13:25 UTC
Message-ID
<CACuz9s31OUWNxTqCmj7ukAo7=TpXK7zBv5kTFZ5obpXKOju9ng@mail.gmail.com>

Recently I had to write some automation scripts and I found that git reset --hard actually restores each file's permissions.

That is causing both the created and the last-modified dates of the file to get changed to the time of the git reset.

This behavior is easy to demonstrate:

echo "test" > myfile chmod 777 myfile git add myfile && git commit -m "Test" && git push chmod 775 myfile git reset --hard origin/master

After the git reset --hard command, the entire file was checkout-ed. Instead, git should be able to check if the content of the file changed and only if it did, check it out.

I do realize that checking the content of each file in a big repo could result in a slow operation, but there should be a switch/argument/option to make git reset actually check the content of each file instead of blindly replacing it.

After reading man a few times I didn't saw any option that'd let me do this; the only solution I'm able to think about is actually restoring the permissions of each file to the ones git thinks they should have before doing the git reset.

Maybe I'm wrong and there is a way for doing what I want, if so, please correct me. But if there isn't, should this be implemented? Are there any reasons for not doing it?

Thank you for your attention Regards

-- alexandernst

Next: Matthieu Moy
Message 1 of 18 in “[Request] Git reset should be able to ignore file permissions”
  1. Alexander NestorovJun 18, 2013
  2. Matthieu MoyJun 18, 2013
  3. Alexander NestorovJun 18, 2013
  4. Matthieu MoyJun 18, 2013
  5. Alexander NestorovJun 18, 2013
  6. Matthieu MoyJun 18, 2013
  7. Alexander NestorovJun 18, 2013
  8. Alexander NestorovJun 18, 2013
  9. Matthieu MoyJun 18, 2013
  10. Alexander NestorovJun 18, 2013
  11. Matthieu MoyJun 19, 2013
  12. Alexander NestorovJun 19, 2013
  13. Matthieu MoyJun 19, 2013
  14. Junio C HamanoJun 19, 2013
  15. Alexander NestorovJun 20, 2013
  16. Hilco WijbengaJun 19, 2013
  17. John KeepingJun 18, 2013
  18. Alexander NestorovJun 18, 2013

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.