基本命令
git --version 检查git是否安装成功
git status 查看版本状态
git reset --hard HEAD/commitID 版本回滚
git add . 添加版本
git commit -m '' 提交版本
git push origin master 推到远程仓库主线分支
git push -f 强行推送
git revert 撤销提交
git config --global user.name ‘username’ //username git账号
git config --global user.email ‘email ‘ //email git邮箱 配置用户
克隆
git clone 克隆分支
分支命令
git branch 查看分支
git branch dev 创建dev分支
git branch -d dev 删除dev分支
git switch/checkout dev 转换到dev分支
git switch/checkout -b dev 创建并转换到dev分支
git merge 合并分支
强制删除本地分支:git branch -D 分支名称
删除远程分支:git push origin --delete 分支名称
查看历史
git log
git reflog
git log --graph
自定义版 git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
简洁版: git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
————————————————
版权声明:本文为优快云博主「_Rookie._」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.youkuaiyun.com/gu2022_3_5_21_23/article/details/124873982