常用语句
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| # 原封不动复制下来 git clone https://github.com/zennnnnnnnnnnn/dqn.git
# 新建 git init git add . # 有新文件需要add git commit -m "上传说明" # 只有内容改动可以直接git commit -a git remote add origin https://github.com/zennnnnnnnnnnn/dqn.git git push -u origin main # 首次上传需要-u origin [branch],以后直接push
# 中途参与: init -> remote -> git pull origin main # 要是本地有改变,无法直接pull,但是会显示error,建议先用git status检查状态 # 强制覆盖:git push -f origin master
# 其他 git status # 查看提交状态 git rm # 删除文件
|
高级语句
1 2 3 4 5
| # 1. 查看历史版本
git log --oneline # 简洁版本 git reflog # 查看包括撤回、删除在内的操作以及版本 git reset --hard [HEAD] # 回滚到指定版本
|
- gitignore
创建一个.gitignore文件,按照https://blog.csdn.net/ThinkWon/article/details/101447866写入不需要上传的文件。
- 分支
1 2 3 4 5 6 7 8
| git branch [name] # 创建分支 git checkout [name] # 切换分支
git branch # 查看所有分支
git checkout -b [name] # 创建并切换到分支 git branch -d [name] # 删除分支
|
commit message格式
1
| <type>(<scope>): <subject>
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| type: feat:新功能(feature)。
fix/to:修复bug,可以是QA发现的BUG,也可以是研发自己发现的BUG。
- fix:产生diff并自动修复此问题。适合于一次提交直接修复问题 - to:只产生diff不自动修复此问题。适合于多次提交。最终修复问题提交时使用fix
docs:文档(documentation)。
style:格式(不影响代码运行的变动)。
refactor:重构(即不是新增功能,也不是修改bug的代码变动)。
perf:优化相关,比如提升性能、体验。
test:增加测试。
chore:构建过程或辅助工具的变动。
revert:回滚到上一个版本。
merge:代码合并。
sync:同步主线或分支的Bug。 scope: 更新范围 subject: 具体描述
|
如:
1 2
| fix(DAO):用户查询缺少username属性 feat(Controller):用户查询接口开发
|
其他
1 2 3
| # 把目录添加到信任列表 git config --global --add safe.directory /media/data/users/jhu3szh/serialize
|