(window.webpackJsonp=window.webpackJsonp||[]).push([[1113],{1521:function(e,t,a){"use strict";a.r(t);var i=a(31),s=Object(i.a)({},(function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[a("h1",{attrs:{id:"configuration"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#configuration"}},[e._v("#")]),e._v(" Configuration")]),e._v(" "),a("h2",{attrs:{id:"setting-which-editor-to-use"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#setting-which-editor-to-use"}},[e._v("#")]),e._v(" Setting which editor to use")]),e._v(" "),a("p",[e._v("There are several ways to set which editor to use for committing, rebasing, etc.")]),e._v(" "),a("li",[e._v("\nChange the `core.editor` configuration setting.\n"),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config"),a("span",{pre:!0,attrs:{class:"token parameter"}},[e._v(" --global")]),e._v(" core.editor nano")]),e._v("\n\n")])])])]),e._v(" "),a("li",[e._v("\nSet the `GIT_EDITOR` environment variable.\nFor one command:\n"),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("$ GIT_EDITOR=nano git commit\n\n")])])]),a("p",[e._v("Or for all commands run in a terminal. "),a("strong",[e._v("Note:")]),e._v(" This only applies until you close the terminal.")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("$ export GIT_EDITOR=nano\n\n")])])])]),e._v(" "),a("li",[e._v("\nTo change the editor for **all** terminal programs, not just Git, set the `VISUAL` or `EDITOR` environment variable. (See [`VISUAL` vs `EDITOR`](https://unix.stackexchange.com/questions/4859/visual-vs-editor-whats-the-difference).)\n"),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("$ export EDITOR=nano\n\n")])])]),a("p",[a("strong",[e._v("Note:")]),e._v(" As above, this only applies to the current terminal; your shell will usually have a configuration file to allow you to set it permanently. (On "),a("code",[e._v("bash")]),e._v(", for example, add the above line to your "),a("code",[e._v("~/.bashrc")]),e._v(" or "),a("code",[e._v("~/.bash_profile")]),e._v(".)")])]),e._v(" "),a("p",[e._v("Some text editors (mostly GUI ones) will only run one instance at a time, and generally quit if you already have an instance of them open. If this is the case for your text editor, Git will print the message "),a("code",[e._v("Aborting commit due to empty commit message.")]),e._v(" without allowing you to edit the commit message first. If this happens to you, consult your text editor's documentation to see if it has a "),a("code",[e._v("--wait")]),e._v(" flag (or similar) that will make it pause until the document is closed.")]),e._v(" "),a("h2",{attrs:{id:"auto-correct-typos"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#auto-correct-typos"}},[e._v("#")]),e._v(" Auto correct typos")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --global help.autocorrect 17\n\n")])])]),a("p",[e._v("This enables autocorrect in git and will forgive you for your minor mistakes (e.g. "),a("code",[e._v("git stats")]),e._v(" instead of "),a("code",[e._v("git status")]),e._v("). The parameter you supply to "),a("code",[e._v("help.autocorrect")]),e._v(" determines how long the system should wait, in tenths of a second, before automatically applying the autocorrected command. In the command above, 17 means that git should wait 1.7 seconds before applying the autocorrected command.")]),e._v(" "),a("p",[e._v("However, bigger mistakes will be considered as missing commands, so typing something like "),a("code",[e._v("git testingit")]),e._v(" would result in "),a("code",[e._v("testingit is not a git command.")])]),e._v(" "),a("h2",{attrs:{id:"username-and-email-address"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#username-and-email-address"}},[e._v("#")]),e._v(" Username and email address")]),e._v(" "),a("p",[e._v("Right after you install Git, the first thing you should do is set your username and email address. From a shell, type:")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --global user.name "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"Mr. Bean"')]),e._v("\ngit config --global user.email mrbean@example.com\n\n")])])]),a("ul",[a("li",[a("code",[e._v("git config")]),e._v(" is the command to get or set options")]),e._v(" "),a("li",[a("code",[e._v("--global")]),e._v(" means that the configuration file specific to your user account will be edited")]),e._v(" "),a("li",[a("code",[e._v("user.name")]),e._v(" and "),a("code",[e._v("user.email")]),e._v(" are the keys for the configuration variables; "),a("code",[e._v("user")]),e._v(" is the section of the configuration file. "),a("code",[e._v("name")]),e._v(" and "),a("code",[e._v("email")]),e._v(" are the names of the variables.")]),e._v(" "),a("li",[a("code",[e._v('"Mr. Bean"')]),e._v(" and "),a("code",[e._v("mrbean@example.com")]),e._v(" are the values that you're storing in the two variables. Note the quotes around "),a("code",[e._v('"Mr. Bean"')]),e._v(", which are required because the value you are storing contains a space.")])]),e._v(" "),a("h2",{attrs:{id:"multiple-git-configurations"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#multiple-git-configurations"}},[e._v("#")]),e._v(" Multiple git configurations")]),e._v(" "),a("p",[e._v("You have up to 5 sources for git configuration:")]),e._v(" "),a("li",[e._v("6 files:\n"),a("ul",[e._v("\n- **`%ALLUSERSPROFILE%\\Git\\Config`** (Windows only)\n"),a("li",[e._v("(system) **`"),a("git",[e._v("/etc/gitconfig`**, with `"),a("git",[e._v("` being the git installation path."),a("br"),e._v("\n(on Windows, it is **`"),a("git",[e._v("\\mingw64\\etc\\gitconfig`**)")])],1)],1)],1),e._v("\n- (system) **`$XDG_CONFIG_HOME/git/config`** (Linux/Mac only)\n- (global) `~/.gitconfig` (Windows: `%USERPROFILE%\\.gitconfig`)\n- (local) `.git/config` (within a git repo `$GIT_DIR`)\n- a **dedicated file** (with `git config -f`), used for instance to modify the config of submodules: `git config -f .gitmodules ...`\n"),a("p",[e._v("The order is important: any config set in one source can be overridden by a source listed below it.")]),e._v(" "),a("p",[a("code",[e._v("git config --system/global/local")]),e._v(" is the command to list 3 of those sources, but only git config -l would list "),a("strong",[e._v("all")]),e._v(" "),a("strong",[e._v("resolved")]),e._v(" configs."),a("br"),e._v('\n"resolved" means it lists only the final overridden config value.')]),e._v(" "),a("p",[e._v("Since git 2.8, if you want to see which config comes from which file, you type:")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --list --show-origin\n\n")])])]),a("h2",{attrs:{id:"list-and-edit-the-current-configuration"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#list-and-edit-the-current-configuration"}},[e._v("#")]),e._v(" List and edit the current configuration")]),e._v(" "),a("p",[e._v("Git config allows you to customize how git works. It is commonly used to set your name and email or favorite editor or how merges should be done.")]),e._v(" "),a("p",[e._v("To see the current configuration.")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config"),a("span",{pre:!0,attrs:{class:"token parameter"}},[e._v(" --list")])]),e._v("\n...\ncore.editor=vim\ncredential.helper=osxkeychain\n...\n\n")])])]),a("p",[e._v("To edit the config:")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config ")]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config core.ignorecase true")]),e._v("\n\n")])])]),a("p",[e._v("If you intend the change to be true for all your repositories, use "),a("code",[e._v("--global")])]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config"),a("span",{pre:!0,attrs:{class:"token parameter"}},[e._v(" --global")]),e._v(" user.name ")]),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"Your Name"')]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config"),a("span",{pre:!0,attrs:{class:"token parameter"}},[e._v(" --global")]),e._v(" user.email ")]),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"Your Email"')]),e._v("\n"),a("span",{pre:!0,attrs:{class:"token command"}},[e._v("$ git config"),a("span",{pre:!0,attrs:{class:"token parameter"}},[e._v(" --global")]),e._v(" core.editor vi")]),e._v("\n\n")])])]),a("p",[e._v("You can list again to see your changes.")]),e._v(" "),a("h2",{attrs:{id:"multiple-usernames-and-email-address"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#multiple-usernames-and-email-address"}},[e._v("#")]),e._v(" Multiple usernames and email address")]),e._v(" "),a("p",[e._v("Since Git 2.13, multiple usernames and email addresses could be configured by using a folder filter.")]),e._v(" "),a("h3",{attrs:{id:"example-for-windows"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#example-for-windows"}},[e._v("#")]),e._v(" Example for Windows:")]),e._v(" "),a("h3",{attrs:{id:"gitconfig"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#gitconfig"}},[e._v("#")]),e._v(" .gitconfig")]),e._v(" "),a("p",[e._v("Edit: "),a("code",[e._v("git config --global -e")])]),e._v(" "),a("p",[e._v("Add:")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("[includeIf "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"gitdir:D:/work"')]),e._v("]\n path = .gitconfig-work.config\n\n[includeIf "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"gitdir:D:/opensource/"')]),e._v("]\n path = .gitconfig-opensource.config\n\n")])])]),a("ul",[a("li",[e._v('The order is depended, the last one who matches "wins".')]),e._v(" "),a("li",[e._v("the "),a("code",[e._v("/")]),e._v(" at the end is needed - e.g. "),a("code",[e._v('"gitdir:D:/work"')]),e._v(" won't work.")]),e._v(" "),a("li",[e._v("the "),a("code",[e._v("gitdir:")]),e._v(" prefix is required.")])]),e._v(" "),a("h3",{attrs:{id:"gitconfig-work-config"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#gitconfig-work-config"}},[e._v("#")]),e._v(" .gitconfig-work.config")]),e._v(" "),a("p",[e._v("File in the same directory as "),a("strong",[e._v(".gitconfig")])]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("[user]\n name = Money\n email = work@somewhere.com\n\n")])])]),a("h3",{attrs:{id:"gitconfig-opensource-config"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#gitconfig-opensource-config"}},[e._v("#")]),e._v(" .gitconfig-opensource.config")]),e._v(" "),a("p",[e._v("File in the same directory as "),a("strong",[e._v(".gitconfig")])]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("[user]\n name = Nice\n email = cool@opensource.stuff\n\n")])])]),a("h3",{attrs:{id:"example-for-linux"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#example-for-linux"}},[e._v("#")]),e._v(" Example for Linux")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("[includeIf "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"gitdir:~/work/"')]),e._v("]\n path = .gitconfig-work\n[includeIf "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"gitdir:~/opensource/"')]),e._v("]\n path = .gitconfig-opensource\n\n")])])]),a("p",[e._v("The file content and notes under section Windows.")]),e._v(" "),a("h2",{attrs:{id:"configuring-line-endings"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#configuring-line-endings"}},[e._v("#")]),e._v(" Configuring line endings")]),e._v(" "),a("h3",{attrs:{id:"description"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#description"}},[e._v("#")]),e._v(" Description")]),e._v(" "),a("p",[e._v("When working with a team who uses different operating systems (OS) across the project, sometimes you may run into trouble when dealing with line endings.")]),e._v(" "),a("h3",{attrs:{id:"microsoft-windows"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#microsoft-windows"}},[e._v("#")]),e._v(" Microsoft Windows")]),e._v(" "),a("p",[e._v("When working on Microsoft Windows operating system (OS), the line endings are normally of form - carriage return + line feed (CR+LF). Opening a file which has been edited using Unix machine such as Linux or OSX may cause trouble, making it seem that text has no line endings at all. This is due to the fact that Unix systems apply different line-endings of form line feeds (LF) only.")]),e._v(" "),a("p",[e._v("In order to fix this you can run following instruction")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --global core.autocrlf=true\n\n")])])]),a("p",[e._v("On "),a("strong",[e._v("checkout")]),e._v(", This instruction will ensure line-endings are configured in accordance with Microsoft Windows OS (LF -> CR+LF)")]),e._v(" "),a("h3",{attrs:{id:"unix-based-linux-osx"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#unix-based-linux-osx"}},[e._v("#")]),e._v(" Unix Based (Linux/OSX)")]),e._v(" "),a("p",[e._v("Similarly, there might be issues when the user on Unix based OS tries to read files which have been edited on Microsoft Windows OS. In order to prevent any unexpected issues run")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --global core.autocrlf=input\n\n")])])]),a("p",[e._v("On "),a("strong",[e._v("commit")]),e._v(", this will change line-endings from CR+LF -> +LF")]),e._v(" "),a("h2",{attrs:{id:"configuration-for-one-command-only"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#configuration-for-one-command-only"}},[e._v("#")]),e._v(" configuration for one command only")]),e._v(" "),a("p",[e._v("you can use "),a("code",[e._v("-c =")]),e._v(" to add a configuration only for one command.")]),e._v(" "),a("p",[e._v("To commit as an other user without having to change your settings in .gitconfig :")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git -c user.email = mail@example commit -m "),a("span",{pre:!0,attrs:{class:"token string"}},[e._v('"some message"')]),e._v("\n\n")])])]),a("p",[e._v("Note: for that example you don't need to precise both "),a("code",[e._v("user.name")]),e._v(" and "),a("code",[e._v("user.email")]),e._v(", git will complete the missing information from the previous commits.")]),e._v(" "),a("h2",{attrs:{id:"setup-a-proxy"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#setup-a-proxy"}},[e._v("#")]),e._v(" Setup a proxy")]),e._v(" "),a("p",[e._v("If you are behind a proxy, you have to tell git about it:")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --global http.proxy http://my.proxy.com:portnumber\n\n")])])]),a("p",[e._v("If you are no more behind a proxy:")]),e._v(" "),a("div",{staticClass:"language-git extra-class"},[a("pre",{pre:!0,attrs:{class:"language-git"}},[a("code",[e._v("git config --global --unset http.proxy\n\n")])])]),a("h4",{attrs:{id:"syntax"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#syntax"}},[e._v("#")]),e._v(" Syntax")]),e._v(" "),a("ul",[a("li",[e._v("git config ["),a("file-option",[e._v("] name [value] # one of the more common use cases of git config")])],1)]),e._v(" "),a("h4",{attrs:{id:"parameters"}},[a("a",{staticClass:"header-anchor",attrs:{href:"#parameters"}},[e._v("#")]),e._v(" Parameters")]),e._v(" "),a("table",[a("thead",[a("tr",[a("th",[e._v("Parameter")]),e._v(" "),a("th",[e._v("Details")])])]),e._v(" "),a("tbody",[a("tr",[a("td",[a("code",[e._v("--system")])]),e._v(" "),a("td",[e._v("Edits the system-wide configuration file, which is used for every user (on Linux, this file is located at "),a("code",[e._v("$(prefix)/etc/gitconfig")]),e._v(")")])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--global")])]),e._v(" "),a("td",[e._v("Edits the global configuration file, which is used for every repository you work on (on Linux, this file is located at "),a("code",[e._v("~/.gitconfig")])])]),e._v(" "),a("tr",[a("td",[a("code",[e._v("--local")])]),e._v(" "),a("td",[e._v("Edits the respository-specific configuration file, which is located at "),a("code",[e._v(".git/config")]),e._v(" in your repository; this is the default setting")])])])])])])])}),[],!1,null,null,null);t.default=s.exports}}]);