Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"git init" failed, what's wrong?

This issue is not same as "Bad git config file .git/config", since it failed when using git init.

It seems there is nothing wrong with /home/mirror/.gitconfig:

[mirror@home php]$ git init
error: Malformed value for push.default: simple
error: Must be one of nothing, matching, tracking or current.
fatal: bad config file line 8 in /home/mirror/.gitconfig

This is the content of ~/.gitignore:

cat ~/.gitconfig
[alias]
        lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
[user]
        email = [email protected]
        name = xxxxx
[push]
        default = simple
like image 395
hugemeow Avatar asked Sep 06 '12 07:09

hugemeow


People also ask

What is git init?

The git init command creates a new Git repository. It can be used to convert an existing, unversioned project to a Git repository or initialize a new, empty repository. Most other Git commands are not available outside of an initialized repository, so this is usually the first command you'll run in a new project.

What do I do after git init?

Once you have initialized the repository, create a remote repository somewhere like GitHub.com. Then, add the remote URL to your local git repository with git remote add origin <URL> .

How do I fix a fatal Not a git repository?

To do so, you need to navigate to the correct folder and then run the command git init , which will create a new empty Git repository or reinitialize an existing one.


2 Answers

Simple was added in git v1.7.11. If your git version is older, this option doesn't exist. Simply remove it from your conf and you'll be able to init repos.

See Documentation

like image 176
Kim E Avatar answered Sep 24 '22 09:09

Kim E


This problem keeps coming up now that git 1.8 is out. Luckily the message from git is now very helpful:

warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

   git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

   git config --global push.default simple

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

For example, emacs interface to git (vc) does not understand the argument 'simple', so you are better off using the argument 'matching' for the time being.

like image 30
Heikki Avatar answered Sep 21 '22 09:09

Heikki