Git config: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 43: Line 43:
The same effect can be achieved by setting [[Git_Environment_Variables#GIT_AUTHOR_NAME|GIT_AUTHOR_NAME]] and [[Git_Environment_Variables#GIT_AUTHOR_EMAIL|GIT_AUTHOR_EMAIL]] environment variables.
The same effect can be achieved by setting [[Git_Environment_Variables#GIT_AUTHOR_NAME|GIT_AUTHOR_NAME]] and [[Git_Environment_Variables#GIT_AUTHOR_EMAIL|GIT_AUTHOR_EMAIL]] environment variables.


To configure commit author information for all repositories the user interacts with (if set on a specific repository, that setting will take precedence):


git config --global user.name "Ovidiu Feodorov"
git config --global user.email "ovidiu@feodorov.com"


To configure it for all repositories the user interacts with (if set on a specific repository, that setting will take precedence):
==Configure an Alias==


{{{
git config --global alias.show-graph 'log --graph --abbrev-commit --pretty=oneline'
git config --global user.name "Ovidiu Feodorov"
git config --global user.email "ovidiu@feodorov.com"
}}}


!!!Configuring an Alias
==push.default==


{{{
This setting affects the behavior of your local client and only when you don't specify which branches you want to push. It can have two values: "matching" and "simple". "matching" means [[git push]] with no argument will push ''all local branches'' to the ones with the same name on the remote. You don't need to establish any special link between the local branch and the remote branch. This also makes it easy to accidentally push a branch you didn't intend to. "simple" means git push will push only the current branch to the one that [[git pull]] would pull from <font color=red>(the link between the local branch and remote branch is established in ...)</font> and also checks that their names match. This is a more intuitive behavior, which is why the default in Git 2.0 is getting changed to this.
git config --global alias.show-graph 'log --graph --abbrev-commit --pretty=oneline'
}}}
 
 
!!!push.default
 
This setting affects the behavior of your local client and only when you don't specify which branches you want to push.
 
It can have two values: "matching" and "simple".
 
"matching" means {{git push}} with no argument will push ''all local branches'' to the ones with the same name on the remote. You don't need to establish any special link between the local branch and the remote branch.  
 
This also makes it easy to accidentally push a branch you didn't intend to.
 
"simple" means git push will push only the current branch to the one that git pull would pull from <font color=red>(the link between the local branch and remote branch is established in ...)</font> and also checks that their names match. This is a more intuitive behavior, which is why the default in Git 2.0 is getting changed to this.


Recommended value is "simple" - it is safer.
Recommended value is "simple" - it is safer.
!!!Remote Manipulation
<font color=red>TODO</font>


=Organizatorium=
=Organizatorium=


  git config --global http.sslVerify true|false
  git config --global http.sslVerify true|false

Revision as of 06:33, 25 November 2017

Internal

Overview

git config is used to manipulate entries in Git's configuration files. There are three levels of configuration files, listed below from the highest precedence to the lowest:

1. file (.git/config). This file contains repository-specific configuration and has the highest precedence. Repository-specific configuration is manipulated when git config is gets the "--file" option. This is the default.

2. global (~/.gitconfig). This file contains user-specific configuration and it is manipulated when git config gets the "--global" option.

3. system (/etc/gitconfig). This file contains system-wide configuration and can be manipulated with the "--system" option, if the user has proper permissions.

The configuration files are not replicated during git clone.

More info:

git config --help

Configuration Operations

List the Configuration

git config -l

Configure a Setting

git config [--file|--global|--system] <some.git.option> <value>

Remove a Setting

git config --unset [--file|--global|--system] <some.git.option>

Recipes

Configure the Commit Author

git config user.name "Ovidiu Feodorov"
git config user.email "ovidiu@feodorov.com"

The same effect can be achieved by setting GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL environment variables.

To configure commit author information for all repositories the user interacts with (if set on a specific repository, that setting will take precedence):

git config --global user.name "Ovidiu Feodorov"
git config --global user.email "ovidiu@feodorov.com"

Configure an Alias

git config --global alias.show-graph 'log --graph --abbrev-commit --pretty=oneline'

push.default

This setting affects the behavior of your local client and only when you don't specify which branches you want to push. It can have two values: "matching" and "simple". "matching" means git push with no argument will push all local branches to the ones with the same name on the remote. You don't need to establish any special link between the local branch and the remote branch. This also makes it easy to accidentally push a branch you didn't intend to. "simple" means git push will push only the current branch to the one that git pull would pull from (the link between the local branch and remote branch is established in ...) and also checks that their names match. This is a more intuitive behavior, which is why the default in Git 2.0 is getting changed to this.

Recommended value is "simple" - it is safer.

Organizatorium

git config --global http.sslVerify true|false