Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smolijar/git-tips
Tips for forgetful I, so I know all the things I need to, when forced to set up git from scratch in new env.
https://github.com/smolijar/git-tips
Last synced: 2 days ago
JSON representation
Tips for forgetful I, so I know all the things I need to, when forced to set up git from scratch in new env.
- Host: GitHub
- URL: https://github.com/smolijar/git-tips
- Owner: smolijar
- Created: 2017-11-02T20:55:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T12:14:20.000Z (almost 4 years ago)
- Last Synced: 2024-05-06T15:17:04.755Z (6 months ago)
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
- awesome-starred - smolijar/git-tips - Tips for forgetful I, so I know all the things I need to, when forced to set up git from scratch in new env. (others)
README
= Git tips
:toc:Tips for forgetful I, so I know all the things I need to, when forced to set up git from scratch in new env.
```
curl https://raw.githubusercontent.com/grissius/git-tips/master/.gitconfig > ~/.gitconfig && echo "Change your name in ~/.gitconfig"
```Sit back and let me guide myself.
== Who am I?
```sh
git config --global user.name "John Doe"
git config user.email [email protected]
```[TIP]
====
*You might want _not_ to set your email globally.*If working on student/work/personal projects, you might want to use different emails.
If you set it globally, you _will always forget_ to change it on new projects.
This way you will be propted :-)
====== Editor
Do set up your editor.
```sh
git config --global core.editor vim
```[TIP]
====
*Use _vim_*If tempted to use one with GUI, just don't.
Been there, done that, not worth it.
If you can swap between insert and normal mode, save and quit,
you are overqualified to use vim for your commit messages.
Else use other CLI editor.
====== Custom GUI difftool
image:http://i0.kym-cdn.com/photos/images/original/001/305/222/ae7.gif[]
It might sound like a brand new excellent idea to you, after discovering GPU acc terminal emulators (like link:https://github.com/kovidgoyal/kitty[kitty]) and inline graphical diffs. Same advice applies. But give it a shot you stubborn rabbit.
== Excludes file
. Don't dodge your IDE temp files while staging changes.
. Don't add them into repository `.gitignore`.
Nobody gives a dayum about which editor you use.
. And for the love of god, do not add them.
. Do create personal `.gitignore`!This is your personal local (unshared) global (over all your local repositories) `.gitignore`.
Use for editor, IDE, system specific files.```sh
git config --global core.excludesfile '~/.gitignore'
```NOTE: All config you set is stored in `~/.gitconfig`. You can edit it there as well.
== Aliases
==== Log
Full colorful tree, all refs.
```
ll2 = log --oneline --graph --all --decorate
ll = log --graph --all --decorate --format=format:'%C(bold cyan)%h%C(reset) %C(dim cyan)(%ar)%C(reset)%C(auto)%d%C(reset) %C(white)%s%C(reset) %C(dim white)(%ae) %C(reset)'
```
`ll2` standard, `ll` custom with dates and authors==== Status
Short (`-s`) removes help and provies just bare summary. Standard provides brief help.
```
st = status -s
sta = status
```==== Commits
`cian` extremely useful for quick patches hook fallouts etc.
```
ci = commit
cia = commit --amend
cian = commit --amend --no-edit
```==== Index/remote
```
rs = reset
ad = add
co = checkout
cob = checkout -b
br = branch
pushu = push -u
```==== Rebasing
```
cp = cherry-pick
rb = rebase
rbi = rebase --interactive
me = merge
```==== Diffing
```
di = diff
dic = diff --cached
wdi = diff --word-diff --color-words
wdic = diff --cached --word-diff --color-words
```==== Branch cleanup
Remove all merged branches (link:https://stackoverflow.com/a/6127884/4425335[credit]), except for _standard_ ones.
```
cutbr = "!git branch --merged | egrep -v '(^\\*|master|dev)' | xargs git branch -d"
```=== Adding aliases
. Add via CLI
+
```sh
git config --global alias.ci commit
```
. Add into `~/.gitconfig`
+
```
[alias]
st = status -s
```