diff --git a/snippets/config-user.md b/snippets/config-user.md new file mode 100644 index 000000000..ccf14009e --- /dev/null +++ b/snippets/config-user.md @@ -0,0 +1,25 @@ +--- +title: Configure git user information +tags: configuration,repository,beginner +--- + +Configures user information for git. + +- Use `git config user.email ` to set the user's email for the current repository. +- Use `git config user.name ` to set the user's name for the current repository. +- You can use the `--global` flag to configure global user information. + +```sh +git config [--global] user.email +git config [--global] user.name +``` + +```sh +git config user.email "cool.duck@qua.ck" +git config user.name "Duck Quackers" +# Configures user for current repository + +git config --global user.email "cool.duck@qua.ck" +git config --global user.name "Duck Quackers" +# Configures global git user +``` diff --git a/snippets/edit-config.md b/snippets/edit-config.md new file mode 100644 index 000000000..c1a8500d3 --- /dev/null +++ b/snippets/edit-config.md @@ -0,0 +1,17 @@ +--- +title: Edit git configuration file +tags: configuration,beginner +--- + +Opens the git configuration file in the git text editor. + +- Use `git config --global -e` to open the git configuration file in the git text editor. + +```sh +git config --global -e +``` + +```sh +git config --global -e +# Opens the git configuration file in the default git text editor +``` diff --git a/snippets/list-aliases.md b/snippets/list-aliases.md new file mode 100644 index 000000000..338666f44 --- /dev/null +++ b/snippets/list-aliases.md @@ -0,0 +1,21 @@ +--- +title: List all git aliases +tags: configuration,intermediate +--- + +Prints a list of all git aliases. + +- Use `git config -l` to list all variables set in the configuration file. +- Use the pipe operator (`|`) to pipe the output and `grep alias` to only keep aliases. +- Use the pipe operator (`|`) to pipe the output and `sed 's/^alias\.//g'` to remove the `alias.` part from each alias. + +```sh +git config -l | grep alias | sed 's/^alias\.//g' +``` + +```sh +git config -l | grep alias | sed 's/^alias\.//g' +# st=status +# co=checkout +# rb=rebase +``` diff --git a/snippets/set-text-editor.md b/snippets/set-text-editor.md new file mode 100644 index 000000000..bd3c5f0f8 --- /dev/null +++ b/snippets/set-text-editor.md @@ -0,0 +1,17 @@ +--- +title: Configure the git text editor +tags: configuration,intermediate +--- + +Configures the text editor used by git. + +- Use `git config --global core.editor ` to call `` as the git text editor. + +```sh +git config --global core.editor +``` + +```sh +git config --global core.editor "code --wait" +# Sets VS Code as the git text editor +```