learngit

感谢足基!感谢Angine学长!~

  • git是目前世界上最先进的分布式版本控制系统。
  • “Git is a free software distributed under the GPL.”
    “Creating a new branch is quick and simple.”

作用

  • 版本管理
  • 协作

常用指令

  • git init初始化一个git仓库
  • git pull 抓取新提交
    git add 添加文件
    git commit -m"" 将暂存区修改一次性提交至分支
    git status 查看工作区状态
  • git diff 查看修改内容
    git log 查看提交历史
    git reflog 查看命令历史
    git reset --hard HEAD^回到上一状态 /commit_id在版本历史中穿梭
    git checkout --file 丢弃工作区修改/恢复误删(用版本库里版本替换)
    git remote add origin git@name:path/reponame.git关联远程库
    git push origin master推送最新修改
    git clone克隆仓库
    git branch查看分支
    git branch <name>创建分支
    git checkout/switch <name> 切换分支
    git merge <name>合并分支
    git checkout -b/switch -c <name> 创建+切换
    git branch -d/-D(强删)删除分支
    git log --graph看分支合并图
    git merge --no-ff -m"" branchname以普通模式合并
    git stash 保存现场 修复bug后
  • git stash pop回到现场
    git cherry-pick <commit> 复制修改
    git remote -v 查看远程库信息
    git branch --set-upstream branchname origin/branchname建立本地分支与远程分支联系
    git rebase git log --graph --pretty=oneline --abbrev-commit整理分支历史成直线

Conventional commit

1.类型(Type)

  • 提交类型指定了该提交的功能或目的。常见的类型包括:
  • feat:新增功能 feat/c
    fix:修复bug
    docs:文档变更
    style:代码样式(不影响功能的改变,如格式化)
    refactor:代码重构(不修复bug也不新增功能)
    perf:性能优化
    test:添加缺失的测试或修复现有的测试
    chore:日常任务(如修改配置文件、构建工具的更新等)
    build:影响构建系统或外部依赖的更改(例如:maven、webpack、gulp等)
    ci:持续集成相关的更改(例如:修改Github Actions、CircleCI配置等)
    revert:撤销先前的提交
    merge:合并提交

建议:

1. “多创建branch”
2. “多commit”

learngit
http://example.com/2025/03/01/learngit/
作者
Lanxinmob
发布于
2025年3月1日
许可协议