86 lines
1.8 KiB
Typst
86 lines
1.8 KiB
Typst
#import "/lib/lib.typ": *
|
|
#set document(title: [Git])
|
|
#metadata((
|
|
title: "Git",
|
|
translation_key: "git",
|
|
summary: "What's git and lot of usefull command"
|
|
)) <website-metadata>
|
|
#calepin.setup(eval: false)
|
|
|
|
= What's Git
|
|
This is git
|
|
|
|
= Bascis command
|
|
TODO:
|
|
- fetch
|
|
- pull
|
|
- push
|
|
- commit (with sign)
|
|
- checkout
|
|
- rebase
|
|
|
|
|
|
= Config
|
|
Git config live in `~/.gitconfig`
|
|
|
|
== User
|
|
In User section, we can specify default `name` and `email`:
|
|
```yaml
|
|
[user]
|
|
name = Rémi Heredero
|
|
email = remi@heredero.ch
|
|
```
|
|
|
|
== Signing
|
|
To sign commit and tag by default, you can set the flag on the configfile:
|
|
```yaml
|
|
[commit]
|
|
gpgsign = true
|
|
[tag]
|
|
gpgSign = true
|
|
```
|
|
You also probably want to specify your default gpg key in the user section:
|
|
```yaml
|
|
[user]
|
|
signingkey = 4A8C1907D8B15B47
|
|
```
|
|
|
|
Sometime (often in windows), you need to specify the path of the gpg program with:
|
|
```yaml
|
|
[gpg]
|
|
program = C:/Users/her/dev/GnuPG/bin/gpg.exe
|
|
```
|
|
|
|
== Default editor
|
|
You can define a default editor to edit commit message or solve conflict. In my case, my favourite code editor is Zed, so:
|
|
```yaml
|
|
[core]
|
|
editor = zed --wait
|
|
```
|
|
|
|
== Include If
|
|
You maybe want a different config for some repo. It's easy to do that with `includeIf`. You can define a gitconfig overlay to apply to a specific repository:
|
|
```yaml
|
|
[includeIf "gitdir:<path-to-work-repo>"]
|
|
path = ~/.gitconfig-work
|
|
```
|
|
= Advanced command
|
|
|
|
== Reset author
|
|
If you didn't use the right config for commiting somewhere, you can reset the author of commit with the following command.
|
|
|
|
=== Single commit
|
|
```sh
|
|
git commit --amend --no-edit --reset-author
|
|
```
|
|
|
|
=== Entire project history
|
|
```sh
|
|
git rebase -r --root --exec "git commit --amend --no-edit --reset-author"
|
|
```
|
|
|
|
=== From a specific commit
|
|
```sh
|
|
git rebase -r <hash> --exec "git commit --amend --no-edit --reset-author"
|
|
```
|