Skip to content

Instantly share code, notes, and snippets.

@dsmith73
Last active November 22, 2023 06:51
Show Gist options
  • Save dsmith73/cc22031410d6660fd6e999608bb9be91 to your computer and use it in GitHub Desktop.
Save dsmith73/cc22031410d6660fd6e999608bb9be91 to your computer and use it in GitHub Desktop.
fatal: bad config line 1 in file .git/config

fatal: bad config line 1 in file .git/config

When I receive this error, the fix is to:

rm -rf .git

Then, I can git init again, with a clean initialization, and it works...


If the solution above doesn't work

Another solution that I found for this is:

  • open .git/config file
  • clear all the NULL values in the file
  • save and close the file
  • git add .

#dsmith73
github.com/dsmith73
@nikarosa
Copy link

thank you! thats what i needed

@willzfrank
Copy link

Worked.. Bless you senior dev.

Copy link

ghost commented Oct 25, 2022

it's not working with me

@SheilaOzorio
Copy link

Hello! It's not working with me too, how did you resolve it?

@dsmith73
Copy link
Author

dsmith73 commented Jan 31, 2023

Added a 2nd possible solution
The issue is that there are a few issues which can cause this problem - and unfortunately, not all will have the same solution.

@saimani1205
Copy link

its does not helps me out bro dev

@saimani1205
Copy link

i receive it at line 9 could you please help me out

@dsmith73
Copy link
Author

What does line 9 in your git/config say?

I'm guessing you can find it in: path/to/project/.git/config

If the fix above didn't work for you, then I'd need to see the file to start to understand how to resolve the issue.

@saimani1205
Copy link

saimani1205 commented Oct 20, 2023 via email

@dsmith73
Copy link
Author

2 items

  1. I don't use git on Windows per se - I installed everything in WSL, so I'm dealing with Linux
  2. Those errors look like you have a bad install and it's scanning your user directory.

My suggestion here is that you probably had issues with the install and need to review the installation instructions / re-install git.
If you're going to use git on Windows, then I really suggest creating a folder structure and putting everything in it, so that you have clear path to your code spaces.

For instance, when I did use git on Windows, I made a folder called code, installed inside it, and did everything from within it.

Guessing this isn't the answer you hoped for...

@saimani1205
Copy link

saimani1205 commented Oct 21, 2023 via email

@dsmith73
Copy link
Author

dsmith73 commented Oct 23, 2023

Are you trying to use git with PowerShell or with Linux on WSL?

My setup is:
Win11 > WSL > Ununtu

Then I installed VS Code and finished setting everything up through Terminal.
So, for me, git is installed on Ubuntu, in WSL, not with PowerShell

@saimani1205
Copy link

saimani1205 commented Oct 24, 2023 via email

@dsmith73
Copy link
Author

Unfortunately, I can't assist you much with Git and PowerShell.

But it does look like your potential issue is identified inside your error message

warning: adding embedded git repository: .vscode
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add .vscode
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached .vscode
hint:
hint: See "git help submodule" for more information.

and, it tells you where to go to figure out how to fix it.

@XzavierBauch
Copy link

XzavierBauch commented Nov 17, 2023

It seems you've handled it effectively. The initial steps of removing the Git directory and initializing a new repository are standard procedures. If any future issues arise, reviewing and modifying the .git/config file, as you described, can be a helpful troubleshooting step. My academic journey took a turn for the better when I discovered this https://domypaper.com/ professional writing service paper writers for hire Hiring the best paper writer from here was a decision that aligned with my pursuit of excellence. The paper delivered was more than just a document – it was a testament to the dedication and expertise of the writer. Trusting this service with my writing tasks has been a transformative experience, and if you're seeking a partner in your academic success, hiring the best paper writer here is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment