前置条件
# 清除掉缓存在git中的用户名和密码 ( 可能之前有人用过这台电脑 )
git credential-manager uninstall
# 配置提交代码的人的用户名和邮箱
git config --global user.name "张三" // 配置用户名
git config --global user.email dc@qq.com // 配置邮箱
# 记住自己的用户名和密码
git config --global credential.helper store
# 代码仓库地址
https://gitee.com/beehardy2/fitness-0401.git // 仓库地址
# 仓库账号和密码
账号: 18181358***
密码: 123456
第一次下载(克隆)代码
git clone 仓库地址 // 例如: git clone https://gitee.com/sine_regina/fitness-app-h50224.git
第二次以后下载(拉取)代码
# 每天进公司第一件事情
git pull 仓库地址 分支名 // 例如: git pull origin develop
提交代码步骤【重点】
git add . // 纳入到版本控制
git commit -m "描述信息" // 暂存到本地
# commit一般是一个功能一次 push是一天一次. 一般是下班之前push
# push之前先pull一次
git push 仓库地址 分支名 // 推送到远程服务器仓库 例如: git push origin develop
commit 规范【重点】
git commit -m "type(scope): subject"
git commit -m "feat(整个项目): 搭建项目环境 "
feat:新功能(feature)
fix:修补bug
docs:文档(documentation)
style: 格式(不影响代码运行的变动)
refactor:重构(即不是新增功能,也不是修改bug的代码变动)
test:增加测试
chore:构建过程或辅助工具的变动
其他命令
git status // 查看仓库状态
git branch // 查看当前有哪些分支
git branch 分支名 // 创建分支
git checkout 分支名 // 切换分支
git checkout -b 分支名 // 创建并切换分支
git merge 分支名 // 合并分支