仲灏小栈 仲灏小栈
首页
大前端
后端&运维
其他技术
生活
关于我
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

仲灏

诚意, 正心, 格物, 致知
首页
大前端
后端&运维
其他技术
生活
关于我
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Java

  • Docker

  • Jenkins

  • Nacos

  • SQL

  • Nginx

  • Windows

  • Linux

  • 虚拟机

  • Git

    • Git 实战使用
      • 可视化训练
      • 安装git
      • 配置账号密码
      • 添加公钥
      • 克隆项目
      • 命令
      • git flow
      • commit message
        • 工具
      • changelog
      • 问题记录
        • 问题现象
        • 原因分析
        • 处理方法
        • 问题现象
        • 原因分析
        • 处理方法
    • git flow 步骤解析
    • git 同步
    • git 提交信息规范
    • Git Hooks
    • gitignore
    • GitHub使用Action自动同步Gitee
  • 网络

  • 其他

  • 后端&运维
  • Git
仲灏
2021-12-24
目录

Git 实战使用

# 可视化训练

https://learngitbranching.js.org/?NODEMO=&locale=zh_CN

切换某个分支到某个版本

# 安装git

# 配置账号密码

git config --global --replace-all user.name "your user name"
git config --global --replace-all user.email"your user email"
1
2

# 添加公钥

https://git-scm.com/book/zh/v2/%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8A%E7%9A%84-Git-%E7%94%9F%E6%88%90-SSH-%E5%85%AC%E9%92%A5 (opens new window)

$ ssh-keygen -o
Generating public/private rsa key pair.
Enter file in which to save the key (/home/schacon/.ssh/id_rsa):
Created directory '/home/schacon/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/schacon/.ssh/id_rsa.
Your public key has been saved in /home/schacon/.ssh/id_rsa.pub.
The key fingerprint is:
d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 schacon@mylaptop.local
1
2
3
4
5
6
7
8
9
10

# 克隆项目

# 命令

创建分支 git branch **

切换分支 git cheout **

合并分支 git merge **

# git flow

https://www.git-tower.com/learn/git/ebook/cn/command-line/advanced-topics/git-flow/

git flow init

img

git flow feature help
1

img

git flow feature start express
1

img

# commit message

https://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html

https://github.com/angular/angular/blob/master/CONTRIBUTING.md

每次提交,Commit message 都包括三个部分:Header,Body 和 Footer。

<type>(<scope>): <short summary>
  │       │             │
  │       │             └─⫸ Summary in present tense. Not capitalized. No period at the end.
  │       │
  │       └─⫸ Commit Scope: animations|bazel|benchpress|common|compiler|compiler-cli|core|
  │                          elements|forms|http|language-service|localize|platform-browser|
  │                          platform-browser-dynamic|platform-server|router|service-worker|
  │                          upgrade|zone.js|packaging|changelog|dev-infra|docs-infra|migrations|
  │                          ngcc|ve
  │
  └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test
1
2
3
4
5
6
7
8
9
10
11
  • type

    • feat:新功能(feature)
    • fix:修补bug
    • docs:文档(documentation)
    • style: 格式(不影响代码运行的变动)
    • refactor:重构(即不是新增功能,也不是修改bug的代码变动)
    • test:增加测试
    • chore:构建过程或辅助工具的变动

如果type为feat和fix,则该 commit 将肯定出现在 Change log 之中。其他情况(docs、chore、style、refactor、test)由你决定,要不要放入 Change log,建议是不要。

  • scope

    • 用于说明 commit 影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。
  • subject

    • 是 commit 目的的简短描述,不超过50个字符。
    • imgimg

# 工具

Commitizen (opens new window)是一个撰写合格 Commit message 的工具。

npm install -g commitizen
1

在项目目录里,运行下面的命令,使其支持 Angular 的 Commit message 格式。

commitizen init cz-conventional-changelog --save --save-exact
1

# changelog

自动生成工具

https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-cli

$ npm install -g conventional-changelog-cli
$ cd my-project
$ conventional-changelog -p angular -i CHANGELOG.md -s
1
2
3

# 问题记录

# 问题现象

使用git pull命令时,提示“refusing to merge unrelated histories”。

# 原因分析

云端与本地的仓库不同,例如:不同的分支、或不同的仓库等。

# 处理方法

使用命令**$ git pull origin master --allow-unrelated-histories**进行强制合并。

# 问题现象

.gitignore文件无效

# 原因分析

文件已经被提交过,处于被跟踪状态,所有即使加入.gitignore文件也无效

# 处理方法

删除该目录的缓存git rm -r --cached unpackage

上次更新: 2022/06/05, 20:31:36
闲置笔记本 单网口pve软路由
git flow 步骤解析

← 闲置笔记本 单网口pve软路由 git flow 步骤解析→

最近更新
01
vim日常使用记录
04-02
02
滑动窗口最大值
04-02
03
有效的字母异位词
04-02
更多文章>
Theme by Vdoing | Copyright © 2021-2025 izhaong | github | 蜀ICP备2021031194号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式