fix fatal: --local can only be used inside a git repository error


Git - fatal error - local can only be used inside a git repo
% git config --list --local
fatal: --local can only be used inside a git repository

If you are trying to use --local option along with a git command like config, you will get a fatal error saying local can only be used inside a git repository when you are not inside any git managed repo.

The option --local is associated with a repo that is local and hence you should be inside one of them.

Fix:

Navigate to the directory where you have your code in git and run the command again!

% git config --list --local

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://xxxx:xxxx@github.com/xxxx/repo.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.main.remote=origin
branch.main.merge=refs/heads/main
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.