[Git 在线学习] [Git Documentation]
General flow
1
2
3
|
git add -A
git commit -m "<commit message>"
git push origin main
|
配置 Git
1
2
3
|
git config --global user.name "[name]"
git config --global user.email "[email address]"
git config --global color.ui auto # 启用有帮助的彩色命令行输出
|
将 Git 的默认编辑器修改为 Vim
1
|
git config --global core.editor "vim"
|
查看历史提交信息
修改最后一次 commit 的信息
1
2
|
git commit --amend
git commit --amend --message "xxx" --author "ningz6 <ningz6@126.com>"
|
修改历史 commit 信息
1
2
|
git log --oneline
git rebase -i <>
|
清除历史提交,只保留最新提交
1
2
3
4
5
6
|
git checkout --orphan tmp
git add -A
git commit -m "Initial commit"
git branch -D main # 删除 main 分支
git branch -m main # 重命名新分支
git push origin main # git push --force origin main
|