Skip to content

.git folder staged by running 'git add .' #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vekazt opened this issue Feb 15, 2025 · 3 comments
Open

.git folder staged by running 'git add .' #628

vekazt opened this issue Feb 15, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@vekazt
Copy link

vekazt commented Feb 15, 2025

Describe the bug
Claude called git add ., which resulted in the .git folder itself being added to git

To Reproduce
Steps to reproduce the behavior:

  1. Get Claude to call git add . (this can happen in multiple ways, so not 'exact steps')

Expected behavior
A clear and concise description of what you expected to happen.

Logs
If applicable, add logs to help explain your problem.
`git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
(use "git push" to publish your local commits)

Changes not staged for commit:
(use "git add/rm ..." to update what will be committed)
(use "git restore ..." to discard changes in working directory)
modified: ./.git/config
modified: ./.git/index
modified: ./.git/logs/HEAD
`

Additional context
Add any other context about the problem here.

@vekazt vekazt added the bug Something isn't working label Feb 15, 2025
@hesreallyhim
Copy link

hesreallyhim commented Mar 2, 2025

Can you provide more context? There may be many ways to get Claude to run git add . but why not share at least one of the scenarios that caused this issue for you? The more detail the better.

git is designed to ignore the .git directory by default. Even if I go into a local .git/config and manually change it, that change will not show up if I run git status or git diff. Without further information, it sounds like you (or Claude) got yourselves into a "bad situation" with the repository you're working in. It's very difficult to diagnose this issue with the context that you have provided.

  • Can you share the recent parts of (or, possibly, the entirety of) the conversation that led up to this point?
  • It seems like certain files inside .git/ were modified - can you share the result of git diff so we can see what the modifications are?
  • Can you share the output of git config --list --show-origin? This would indicate if git is utilizing some other configuration files than the default one.
  • With the respect to the "log" can you share the actual content of the little dropdown view that opens when Claude uses MCP and which shows what the MCP server is doing? Again, this might help diagnose the issue.
  • Does this happen in all repos for you? In just one? In multiple?

Without more information, it will be hard to offer you much help.

@soichisumi
Copy link

git is designed to ignore the .git directory by default. Even if I go into a local .git/config and manually change it, that change will not show up if I run git status or git diff.

Theoretically yes, but I also faced this issue two times.
Both times it happened when I gave the following input.

Image

@olamedia
Copy link

olamedia commented May 3, 2025

just met this issue. did undo to 5 commits up to committed .git folder, copied backup of files, then did hard reset to last commit before .git appears in log, replaced files from backup and committed again, but well, lost history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants