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

Are these bugs?

From
Jay Soffian <jaysoffian@gmail.com>
Date
Aug 27, 2008, 23:36 UTC
Message-ID
<76718490808271636i4de8f385pdaeb1672f06a00d7@mail.gmail.com>
1. You can't use reset in a just initialized repo:

$ mkdir testrepo $ cd testrepo $ echo foo > foo $ git init $ git add . $ git reset fatal: Failed to resolve 'HEAD' as a valid ref.

In the real-world, I had initialized a new repository and realized I'd staged extra files I didn't want. I was going to "git reset" then re-add the specific files I wanted, but that obviously failed. I worked around this by using "git rm --cached" to get rid of what I didn't want.

I understand why "git reset" failed, but at best the error message is confusing to a new user.

2. "git add --ignore-errors" doesn't work with ignored files:

$ mkdir testrepo $ cd testrepo $ git init Initialized empty Git repository in /Users/jay/testrepo/.git/ $ echo foo >> .git/info/exclude $ echo foo > foo $ echo bar > bar $ git add --ignore-errors foo bar The following paths are ignored by one of your .gitignore files: foo Use -f if you really want to add them. fatal: no files added

Now you may ask "why are you specifying foo if you don't want to add
it?" In the real-world I was generating the list to "git add" with
xargs and it was quite a long list. It was easiest to filter out what
I didn't want through .git/info/exclude. But I ended up having to "...
| grep -v <stuff I don't want> | xargs git add".

So I think preferable would be: "Use -f if you really want to add them or --ignore errors to continue anyway."

$ git version git version 1.6.0.176.g8698c

Thoughts?
j.
Next: Junio C Hamano
Message 1 of 6 in “Are these bugs?”
  1. Jay SoffianAug 27, 2008
  2. Junio C HamanoAug 27, 2008
  3. Stephan BeyerAug 28, 2008
  4. Junio C HamanoAug 28, 2008
  5. Benny HalevyAug 28, 2008
  6. Jay SoffianAug 28, 2008

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.