til/use-git.md

62 lines
683 B
Markdown

# Use git
Prefer rebase when pull:
```sh
git pull --rebase
```
Clean outdated branches:
```sh
git fetch --prune
```
Push force safely:
```sh
git push --force-with-lease
```
Shallow clone:
```sh
git clone --depth 1 ...
```
Add submodule:
```sh
git submodule add --depth 1 ...
```
First time pull repo with submodules:
```sh
git submodule update --init --recursive
```
Update submodules:
```sh
git submodule update --recursive --remote
```
Save usernames and passwords in `~/.git-credentials`:
```sh
git config --global credential.helper store
```
Use `vim` when commit:
```sh
git config --global core.editor vim
```
Rewrite history:
```sh
git rebase -i HEAD~x
```