Advanced Git
文章目录
- Git concepts
- add & commit & reset
- pull & fetch & merge
- MR & Dev branch
- git add -p <file>
- git commit --amend
- git rebase -i HEAD~3
- git push -f
- Advanced alias
Git concepts
add & commit & reset
pull & fetch & merge
MR & Dev branch
git add -p
partially add file, using similar as vim.
git commit --amend
- modify current commit.
- add current commit.
git rebase -i HEAD~3
rewrite git history.
git push -f
resolve all mistakes locally and force push it to remote.
git push origin HEAD:<branch name> -f
Advanced alias
# or alias push="git status | awk '/On/ { print $3; }' | xargs git push origin"
alias push="git branch | awk '/\*/ { print \$2; }' | xargs git push origin"
alias log="git log -n 10 --pretty=oneline"
alias commit="func() { git commit -m\"\$1\"; }; func"
alias status="git status"