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

Re: gitignore design

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 29, 2011, 13:19 UTC
Message-ID
<m3pqktql6s.fsf@localhost.localdomain>
In-Reply-To
<4E32AE7C.70004@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
Show 19 quoted lines
> Am 7/29/2011 14:19, schrieb Jakub Narebski:
> > For that you can use 'assume-unachanged' mechanism (note: it is local
> > to repository).  The gitignore(7) manpage says:
> > 
> >   NOTES
> >      The purpose of gitignore files is to ensure that certain files not tracked
> >      by git remain untracked.
> > 
> >      To ignore uncommitted changes in a file that is already tracked, use
> >      `git update-index --assume-unchanged <file>`.
> 
> This statement in our documentation is *wrong*!! Please do not suggest it
> for cases like the OP's!
> 
> See the discussion of assume-unchanged in git-update-index: This bit
> actually means that git may assume that the file was not changed, and it
> can take the worktree's data when it otherwise would have to unpack the
> index's data. IOW, using it for the purposes that the OP would need is
> *dangerous*.
Are you sure?  It seems to work as I thought it would.
  $ git init
  Initialized empty Git repository in /tmp/jnareb/test/.git/
  [master!test]$ echo foo >foo
  [master!test]$ echo bar >bar
  [master!test]$ echo bar >.gitignore
  [master!test]$ git add .
  [master!test]$ git commit -m Initial
  [master (root-commit) 522267b] Initial
   2 files changed, 2 insertions(+), 0 deletions(-)
   create mode 100644 .gitignore
   create mode 100644 foo
  [master!test]$ git add -f bar
  [master!test]$ git commit -m 'Add bar (ignored)'
  [master a708f70] Add bar (ignored)
   1 files changed, 1 insertions(+), 0 deletions(-)
   create mode 100644 bar
  [master!test]$ echo foo >>foo
  [master!test]$ echo bar >>bar
  [master!test]$ git status -s
   M bar
   M foo
  [master!test]$ git update-index --assume-unchanged bar
  [master!test]$ git status -s
   M foo
  [master!test]$ git commit -a -m "assume-unchanged bar, both changed"
  [master ec74f8e] assume-unchanged bar, both changed
   1 files changed, 1 insertions(+), 0 deletions(-)
  [master!test]$ git status -s
  [master!test]$ git show
  commit ec74f8e3f3f819bba22453324d7659fe8dd253e8
  Author: Jakub Narebski <jnareb@gmail.com>
  Date:   Fri Jul 29 44 2011 +0200
  
      assume-unchanged bar, both changed
  
  diff --git a/foo b/foo
  index 257cc56..0d55bed 100644
  --- a/foo
  +++ b/foo
  @@ -1 +1,2 @@
   foo
  +foo
Notice that change to 'bar' didn't get comitted.
-- 
Jakub Narębski
Previous: Johannes SixtNext: Johannes Sixt
Message 12 of 20 in “gitignore design”
  1. llucianfJul 29, 2011
  2. Ferry HubertsJul 29, 2011
  3. llucianfJul 29, 2011
  4. Ferry HubertsJul 29, 2011
  5. llucianfJul 29, 2011
  6. Jakub NarebskiJul 29, 2011
  7. llucianfJul 29, 2011
  8. Jakub NarebskiJul 29, 2011
  9. Ferry HubertsJul 29, 2011
  10. Jakub NarebskiJul 29, 2011
  11. Johannes SixtJul 29, 2011
  12. Jakub NarebskiJul 29, 2011
  13. Johannes SixtJul 29, 2011
  14. Jakub NarebskiJul 29, 2011
  15. Nguyen Thai Ngoc DuyJul 30, 2011
  16. Piotr KrukowieckiJul 30, 2011
  17. Nguyen Thai Ngoc DuyJul 30, 2011
  18. Piotr KrukowieckiJul 30, 2011
  19. Clemens BuchacherJul 30, 2011
  20. Philip OakleyJul 29, 2011

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.