27

I would like to format my ~/.gitconfig file, but I don't know the file type. Is it toml or yml or something else?

Do indentations matter? What structure does it expect?

10
  • 2
    Welcome to SO! What do you mean by "kind of format" exactly? It's a configuration text file.
    – ggorlen
    Commented Jul 20, 2021 at 21:39
  • 6
    It has no specific standard format. It's a format that git expects, that's all. It's similar to an ini file, but not quite.
    – KamilCuk
    Commented Jul 20, 2021 at 21:41
  • I would like to know what tool I could use to be able to format the text of the file. Commented Jul 20, 2021 at 21:41
  • 1
    @mfaani No? Resource and tool requests are off topic(point 3).
    – Daedalus
    Commented Jan 30, 2022 at 21:17
  • 1
    this is a good question, when i paste gitconfig code to wiki, the code need be highlight, so how can i set the format for wiki ? Commented Mar 10, 2022 at 4:45

2 Answers 2

20

Which is the file format of ~/.gitconfig?

The format is described in documentation. It has no specific "standard" format. It's just a format that Git expects. It is similar to an ini file, but not quite - there are subsections and values with quotations.

what tool I could use able to format the text of the file

Just do not indent sections and comments and indent any other lines. You can write such a program in sed or awk.

1
  • 1
    If you use vim/neovim you can select all the text and then press =. Commented Nov 29, 2021 at 0:22
4

follow by wiki: https://en.wikipedia.org/wiki/INI_file#cite_note-4 and official doc: https://git-scm.com/docs/git-config#_configuration_file

it is really totally ini file, u can use ini format it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.