diff --git a/aider/repo.py b/aider/repo.py index 0615e3b39..15e89a54f 100644 --- a/aider/repo.py +++ b/aider/repo.py @@ -156,7 +156,10 @@ class GitRepo: # Add staged files index = self.repo.index - staged_files = [item.a_path for item in index.diff("HEAD")] + try: + staged_files = [item.a_path for item in index.diff("HEAD")] + except git.exc.BadName: + staged_files = [item.a_path for item in index.diff(None)] files.extend(staged_files) # convert to appropriate os.sep, since git always normalizes to /