2020-02-17 17:28:12 +00:00
|
|
|
# Use git
|
|
|
|
|
|
|
|
Prefer rebase when pull:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git pull --rebase
|
|
|
|
```
|
|
|
|
|
|
|
|
Clean outdated branches:
|
|
|
|
|
|
|
|
```sh
|
2020-03-19 03:04:02 +00:00
|
|
|
git fetch --prune
|
2020-02-17 17:28:12 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Push force safely:
|
|
|
|
|
|
|
|
```sh
|
2020-03-19 03:04:02 +00:00
|
|
|
git push --force-with-lease
|
2020-02-17 17:28:12 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
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
|
|
|
|
```
|
2020-02-21 10:41:32 +00:00
|
|
|
|
|
|
|
Save usernames and passwords in `~/.git-credentials`:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git config --global credential.helper store
|
|
|
|
```
|
2020-02-27 08:40:49 +00:00
|
|
|
|
|
|
|
Use `vim` when commit:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
git config --global core.editor vim
|
|
|
|
```
|
2020-02-28 20:51:00 +00:00
|
|
|
|
2020-03-19 03:04:02 +00:00
|
|
|
Rewrite history:
|
2020-02-28 20:51:00 +00:00
|
|
|
|
|
|
|
```sh
|
2020-03-19 03:04:02 +00:00
|
|
|
git rebase -i HEAD~x
|
2020-02-28 20:51:00 +00:00
|
|
|
```
|