git
code:git-setup.sh
git config --global user.name hoge
git config --global user.email hoge@example.com
git config --global init.defaultBranch main
git config --global core.autocrlf input
git config --global core.longpaths true # Git for Windows用。気が付いたら設定されてた
git config --global core.quotepath false # 日本語ファイル名をそのまま表示
# alias
git config --global alias.lg "log --graph --oneline --decorate --all"
code:github-auth.sh
gh auth login
# manually
git config --system --unset credential.helper
code:first-commit-should-be-empty.sh
git commit --allow-empty -m "first commit"
code:duplicate-current-branch.sh
git branch -c new-branch
code:delete-local-branch.sh
git branch -d branch-to-del
code:delete-remote-branch.sh
git push -d origin branch-to-del
code:overwrite-current-branch.sh
git fetch origin
git reset --hard origin/hoge
code:force-push.sh
# cancel commit (not recommended)
# git reset --hard HEAD^
# cancel commit, and back to index (addされた状態に戻す)
git reset --soft HEAD~
# force-push if local branch is newer than remote
git push --force-with-lease origin hoge
# force-push (not recommended)
# git push -f origin hoge
# merge/rename commits (interactive)
git rebase -i a5b6c7d~4
code:show-latest-version-tag.sh
# sort by version string (not date)
git tag --sort=-v:refname | head -n5
あとGitKrakenは便利