book-git-commands/src/example/aliases.md

34 lines
1.7 KiB
Markdown
Raw Normal View History

2021-01-08 21:53:46 +00:00
# Aliases
The following are some aliases that I have setup.
2021-08-07 21:51:09 +00:00
Find them by running the following
```bash
git config --get-regexp 'alias.*'
```
2021-01-08 21:53:46 +00:00
## User and Repository Related
```bash
# Define an alias to change user information for a repo.
git config --global alias.workprofile 'config user.email "work@example.com"'
# With the above alias defined, run in a repo directory to switch user information for the specific repo.
git workprofile
```
## Logging
```bash
2021-08-07 20:37:20 +00:00
git config --global alias.last 'log -1 HEAD --stat'
2021-01-08 21:53:46 +00:00
git config --global alias.lg "!git lg1"
git config --global alias.lg1 "!git lg1-specific --all"
git config --global alias.lg2 "!git lg2-specific --all"
git config --global alias.lg3 "!git lg3-specific --all"
git config --global alias.lg1-specific "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'"
git config --global alias.lg2-specific "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'"
git config --global alias.lg3-specific "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'"
```
2023-05-29 21:49:36 +00:00
## Remotes
```bash
git config --global alias.incoming "!git remote update -p; git log ..@{u}"
git config --global alias.outgoing "log @{u}.."
```