til/Applications/git.md

51 lines
726 B
Markdown
Raw Normal View History

2020-05-08 18:48:34 +00:00
# Git
2020-02-17 17:28:12 +00:00
2020-05-10 17:28:17 +00:00
| Distribution | Package |
| ------------ | ------- |
| Archlinux | `git` |
| Ubuntu | `git` |
2020-05-08 18:51:01 +00:00
Add to `~/.bashrc`:
```bash
[[ -f /usr/share/git/completion/git-prompt.sh ]] && \
source /usr/share/git/completion/git-prompt.sh
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
```
2020-05-09 18:30:08 +00:00
Save usernames and passwords in `~/.git-credentials`:
```sh
git config --global credential.helper store
```
Use neovim when commit:
```sh
git config --global core.editor nvim
```
2020-02-17 17:28:12 +00:00
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
```
2020-03-28 15:02:25 +00:00
Rewrite history by changing last `x` commits :
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
```