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

Re: git bug

From
René Scharfe <l.s.r@web.de>
Date
Aug 6, 2020, 20:23 UTC
Message-ID
<5387a5b7-4551-53a0-abdb-e26cc2702536@web.de>
In-Reply-To
<1596725319.6764.7.camel@free.fr>
Am 06.08.20 um 16:48 schrieb PANEL Christian:
Show 5 quoted lines
> someting is not logical in the behaviour of git :
>
> suppose I have a project and a file in it I don't want to include initially in.
> so I put this file name in .gitignore
> now all is OK when I write "git status" : the file is ignored.
Like this, right?
  $ git init a
  Initialized empty Git repository in /tmp/a/.git/
  $ cd a
  $ echo ignore for now >file
  $ echo file >.gitignore
  $ git add .gitignore
  $ git commit -m initial
  [master (root-commit) 2df5d68] initial
   1 file changed, 1 insertion(+)
   create mode 100644 .gitignore
  $ git status
  On branch master
  nothing to commit, working tree clean
Show 6 quoted lines
> but later I want this one be a part of my project.
> I delete in .gitignore the line that named this file.
> but now a "git status" command ignore always this file.
>
> what is wrong ?
> did I missed something ?
This seems to work as expected for me (continued from above):
  $ >.gitignore
  $ git status
  On branch master
  Changes not staged for commit:
    (use "git add <file>..." to update what will be committed)
    (use "git restore <file>..." to discard changes in working directory)
  	modified:   .gitignore
  Untracked files:
    (use "git add <file>..." to include in what will be committed)
  	file
  no changes added to commit (use "git add" and/or "git commit -a")

So "file" is no longer ignored. Committing the .gitignore change doesn't change that:

  $ git add .gitignore
  $ git commit -m 2nd
  [master d4c95a1] 2nd
   1 file changed, 1 deletion(-)
  $ git status
  On branch master
  Untracked files:
    (use "git add <file>..." to include in what will be committed)
  	file
  nothing added to commit but untracked files present (use "git add" to track)
Which steps did you take to arrive at a different result?
René
Previous: PANEL ChristianNext: Jeff King
Message 2 of 5 in “git bug”
  1. PANEL ChristianAug 6, 2020
  2. René ScharfeAug 6, 2020
  3. Jeff KingAug 7, 2020
  4. René ScharfeAug 10, 2020
  5. PANEL ChristianAug 10, 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.