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

Re: Honoring a checked out gitattributes file

From
Jeff King <peff@peff.net>
Date
Jan 28, 2009, 17:55 UTC
Message-ID
<20090128175545.GE8863@coredump.intra.peff.net>
In-Reply-To
<498078F1.20807@trolltech.com>
On Wed, Jan 28, 2009 at 04:25:37PM +0100, Kristian Amlie wrote:
Show 6 quoted lines
> However, if the .gitattributes file is also checked in to the branch, it
> will not always be honored. I browsed the code a bit, and it seems to
> happen whenever there is an existing .gitattributes file, but the
> checkout adds new files to it. These new files will not get the correct
> line endings (although I'm not sure if it happens *every* time, it could
> depend on the order they are checked out).

This is a known limitation of gitattributes. There has been some discussion in the past on how it should work, but I don't recall the specifics; try searching the list archive. I think it is really just waiting for somebody to step up and write some patches.

As a workaround, you might be able to do something like:
  branch=master
  git show $branch:.gitattributes >.git/info/attributes
  git checkout $branch

which is very hacky, but might work depending on your setup. Notably it will overwrite any actual use you were making of .git/info/attributes, and it will not respect any .gitattributes files in subdirectories.

-Peff
Previous: Kristian Amlie
Message 22 of 22 in “Honoring a checked out gitattributes file”
  1. Kristian AmlieJan 28, 2009
  2. Michael J GruberJan 28, 2009
  3. Kristian AmlieJan 28, 2009
  4. Kristian AmlieJan 30, 2009
  5. Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Jan 30, 2009
  6. Kristian AmlieMar 12, 2009
  7. 1/2 Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Mar 12, 2009
  8. 2/2 Make Git respect changes to .gitattributes during checkout.Kristian Amlie, Mar 12, 2009
  9. Johannes SixtMar 12, 2009
  10. Kristian AmlieMar 12, 2009
  11. Kristian AmlieMar 13, 2009
  12. 1/2 Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Mar 13, 2009
  13. 2/2 Make Git respect changes to .gitattributes during checkout.Kristian Amlie, Mar 13, 2009
  14. Junio C HamanoMar 14, 2009
  15. Kristian AmlieMar 19, 2009
  16. Junio C HamanoMar 19, 2009
  17. Kristian AmlieMar 20, 2009
  18. Add a test for checking whether gitattributes is honored by checkout.Kristian Amlie, Mar 20, 2009
  19. Junio C HamanoMar 14, 2009
  20. Matthieu MoyMar 12, 2009
  21. Kristian AmlieMar 12, 2009
  22. Jeff KingJan 28, 2009

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.