Add configuration snippets

This commit is contained in:
Isabelle Viktoria Maciohsek
2021-04-04 21:25:22 +03:00
parent 2c0ba554cd
commit 38ccf0471e
4 changed files with 80 additions and 0 deletions

25
snippets/config-user.md Normal file
View 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
View 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
View 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
```

View 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
```