Skip to content

Commit c4103cd

Browse files
committed
docs: Added git tricks section
1 parent 0bdaa85 commit c4103cd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

docs/bag-of-tricks.md

+30
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,36 @@ yarn () {
3030
}
3131
```
3232

33+
## Git tricks
34+
35+
### Aliases
36+
37+
Aliases to easily update your main branch, e.g after PR was merged.
38+
It updates the branch in the background before switching to it, so that editor/tooling experience the least changes.
39+
40+
- `upc`: update specified branch (defaults to `main`), and switch to it
41+
- `upd`: update specified branch (defaults to `main`)
42+
43+
```
44+
[alias]
45+
upc = "!git updonly \"${1:-main}\" && git checkout \"${1:-main}\" || git pull #"
46+
upd = "!git updonly \"${1:-main}\" || git pull #"
47+
updonly = "!git fetch `git gitremote \"$1\"` \"$1\":\"$1\" #"
48+
gittrack = "!git for-each-ref --format='%(upstream:short)' $(git rev-parse --symbolic-full-name \"$1\") #"
49+
gitremote = "!git gittrack \"$1\" | sed 's@/.*@@' #"
50+
```
51+
52+
### Other recommendations
53+
54+
```
55+
[pull]
56+
rebase = true
57+
[rebase]
58+
autoStash = true
59+
[init]
60+
defaultBranch = main
61+
```
62+
3363
## Znap - Oh My Posh and pnpm auto completion support
3464

3565
Install oh-my-posh, install pnpm autocomple zsh, and use:

0 commit comments

Comments
 (0)