配置命令
git config user.name <name> git config user.email <email> git config --global user.name <name> git config --global user.email <email>
git config --global color.ui true git config --global color.status auto git config --global color.diff auto git config --global color.branch auto git config --global color.interactive auto
git config --global --unset http.proxy <proxy> git config --global --unset http.proxy <proxy>
git config --global --unset http.proxy git config --global --unset https.proxy
git config list
|
基础命令
git init
git clone <url>
git add <pathspec>
git rm <pathspec>
git rm --cached <pathspec>
git status
git log
git log --graph
git log --graph --pretty=oneline --abbrev-commit
git commit -m <message> git commit --amend -m <message> git commit -am <message>
git remote -v git remote add origin <url> git remote rm origin
git remote set-url origin <git.url>
git pull git pull origin master
git push git push -u origin master
git push -f
git branch --set-upstream-to=origin/master master
git switch -c main
|
进阶命令
git diff git diff --cached
git reset --hard HEAD^ git reset <版本号>
git reflog
git branch git branch <branch> git branch -d <branch>
git tag <name>
git show <name>
git push origin --tags
git checkout git checkout <branch> git checkout -b <branch>
git merge <branch>
git fetch
git fetch --prune
git merge --no-ff -m "merge with no-ff" <branch>
git stash git stash list git stash drop git stash apply git stash pop git stash apply stash@{0}
git cherry-pick <版本号>
git checkout 1acd5de
git switch -c <新分支名>
git switch -
git push --force --set-upstream origin <branch>
|
替换分支
git checkout main git merge -s ours master git checkout master git merge main
|
子模块
git submodule
git submodule init
git submodule add <项目地址> <路径>
git submodule add -b v1.0 <项目地址> <路径>
git submodule update --init --remote --recursive
git rm -rf --cached <路径>
|
zsh 快捷命令
gapa git add --patch gc! git commit -v --amend gcl git clone --recursive gclean git reset --hard && git clean -dfx gcm git checkout master gcmsg git commit -m gco git checkout gd git diff gdca git diff --cached gp git push grbc git rebase --continue gst git status gup git pull --rebase
|
分支命名规范
分支 |
命名 |
说明 |
主分支 |
main/master |
主分支,所有提供给用户使用的正式版本,都在这个主分支上发布 |
开发主分支 |
dev |
开发分支,永远是功能最新最全的分支 |
功能分支 |
feature-* |
新功能分支,某个功能点正在开发阶段 |
发布版本 |
release-* |
发布定期要上线的功能 |
修复发布版本分支 |
bugfix-release-* |
修复测试bug |
紧急修复分支 |
bugfix-master-* |
紧急修复线上代码的 bug |
工作流程图
Github
![]()
Gitlab
![]()
------------ 已触及底线了 感谢您的阅读 ------------