Git cheat sheet
Git のよく使ったりたまにしか使わないから忘れるコマンドたち
git commit --fixup <commit-ref>
git rebase -i --autosquash <commit-ref>
bitcoin/doc/productivity.md at v25.1 · bitcoin/bitcoin
Stash
stash の diff を確認する
git stash show -p <name>
name で restore する
code:shell
git stash apply stash^{/STASH_NAME}
Pull rebase
GitHub で suggest 受けて UI で commit した。その間にもローカルの履歴が進んでいる。当然ただ pull すると ff にならないので rebase option をつける
code:shell
git pull origin branch -r
Check status changes
code:shell
git status -v
任意の commit のときのファイルの状態を知る
Git - git-show Documentation
code:terminal
git show <commit>:<file>
git pull force
version control - How do I force "git pull" to overwrite local files? - Stack Overflow
code:terminal
git reset --hard origin/branchname
Cleanup
remove merged branches
$ git branch --merged | grep -v '*' | xargs -I % git branch -d %
remote tracking branchs
$ git fetch --prune
Git - git-fetch Documentation
$ git remote prune origin
Squash all commit into one
code:terminal
git reset $(git commit-tree HEAD^{tree} -m "initila commit")
https://stackoverflow.com/a/23486788
Setup remote repository
code:terminal
git remove -v // Show remote repositories
git remote add upstream git@github.com:madoka/magika.git
Merge without merge commit
code:shell
git merge <branch> --no-commit
Modify old commit message
code:shell
git rebase -i ...
use reword directive
Diff
Diff of commit A and parent commit of A
code:shell
git diff A^ A
Switch to remote branch
$ git fetch origin
$ git switch -c branch_name
if there is origin/branch_name, branch_name branch will be created
$ git switch -c branch remote/branch
これ使っておけば間違いない
$ git switch --detach branch_name
reflog
Git - git-reflog Documentation
git reset <reflog で確認したid>
Different ways to use “--patch” in Git | tekin.co.uk
直前の commit をステージングに戻す
$ git reset --soft HEAD^
作業ディレクトリにまで戻すには git reset HEAD^ ???