Add configuration snippets
This commit is contained in:
25
snippets/config-user.md
Normal file
25
snippets/config-user.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
title: Configure git user information
|
||||||
|
tags: configuration,repository,beginner
|
||||||
|
---
|
||||||
|
|
||||||
|
Configures user information for git.
|
||||||
|
|
||||||
|
- Use `git config user.email <email>` to set the user's email for the current repository.
|
||||||
|
- Use `git config user.name <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 <email>
|
||||||
|
git config [--global] user.name <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
|
||||||
|
```
|
||||||
17
snippets/edit-config.md
Normal file
17
snippets/edit-config.md
Normal file
@ -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
|
||||||
|
```
|
||||||
21
snippets/list-aliases.md
Normal file
21
snippets/list-aliases.md
Normal file
@ -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
|
||||||
|
```
|
||||||
17
snippets/set-text-editor.md
Normal file
17
snippets/set-text-editor.md
Normal file
@ -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 <editor-command>` to call `<editor-command>` as the git text editor.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git config --global core.editor <editor-command>
|
||||||
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git config --global core.editor "code --wait"
|
||||||
|
# Sets VS Code as the git text editor
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user