Kevin's blog Kevin's blog
首页
  • Java基础
  • Java高级
  • MySQL
  • JDBC
  • Java 8新特性
  • 原生Servlet
  • 延迟队列
  • 分布式事务
  • ActiveMQ
  • Elasticsearch
  • Stream API
  • Redis 实战(黑马程序员)
  • Redis 课程(尚硅谷)
  • Redis数据类型和常用命令
  • 版本控制
  • Spring Framework
  • Spring MVC Framework
  • MyBatis Framework
  • MyBatis Plus Framework
  • Spring Boot Framework
  • 韩顺平 Spring Boot Framework
  • 在线教育
  • 谷粒商城 - 分布式基础 高级 集群
  • 谷粒商城 - 详细开发文档
  • docker基础
  • docker-compose容器编排
  • docker swarm集群管理
  • Vue2基础
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)

Kevin

Java系统笔记
首页
  • Java基础
  • Java高级
  • MySQL
  • JDBC
  • Java 8新特性
  • 原生Servlet
  • 延迟队列
  • 分布式事务
  • ActiveMQ
  • Elasticsearch
  • Stream API
  • Redis 实战(黑马程序员)
  • Redis 课程(尚硅谷)
  • Redis数据类型和常用命令
  • 版本控制
  • Spring Framework
  • Spring MVC Framework
  • MyBatis Framework
  • MyBatis Plus Framework
  • Spring Boot Framework
  • 韩顺平 Spring Boot Framework
  • 在线教育
  • 谷粒商城 - 分布式基础 高级 集群
  • 谷粒商城 - 详细开发文档
  • docker基础
  • docker-compose容器编排
  • docker swarm集群管理
  • Vue2基础
  • 前端文章

    • JavaScript
  • 学习笔记

    • 《JavaScript教程》
    • 《JavaScript高级程序设计》
    • 《ES6 教程》
    • 《Vue》
    • 《React》
    • 《TypeScript 从零实现 axios》
    • 《Git》
    • TypeScript
    • JS设计模式总结
  • HTML
  • CSS
  • 技术文档
  • GitHub技巧
  • Nodejs
  • 博客搭建
  • 学习
  • 面试
  • 心情杂货
  • 实用技巧
  • 友情链接
关于
收藏
  • 分类
  • 标签
  • 归档
GitHub (opens new window)
  • Java基础

  • Java高级

  • MySQL

  • JDBC

  • Java8新特性

  • 原生Servlet

  • 延迟队列

  • 分布式事务

  • ActiveMQ

  • Elasticsearch

  • Stream

  • 黑马程序员Redis实战

  • 版本控制

    • 版本控制指南
      • 主要
        • 基础篇
        • 1. git commit
        • 2. git branch
        • 3. git merge
        • 4. git rebase
        • 4. git stash (暂存)
        • 高级篇
        • 1. 分离 HEAD
        • 2. 相对引用 (^)
        • 3.相对引用2(~)
        • 4.撤销变更
        • 移动提交记录
        • 1.Git Cherry-pick
        • 2. 交互式 rebase
        • 杂项
        • 1. 只取一个提交记录
        • 2.提交的技巧 #1 -
        • 3.提交的技巧 #2 -
        • 4.Git Tag
        • 5.Git Describe
        • 高级话题
        • 1. 多次 Rebase
        • 2. 两个父节点
        • 3. 纠缠不清的分支
      • 远程
        • Push & Pull —— Git 远程仓库!
        • 1. git clone
        • 2. 远程分支
        • 3. git fetch
        • 4. git pull
        • 5. 模拟团队合作
        • 6.git push
        • 7. 偏离的提交历史
        • 8.锁定的Master(Locked Master)
        • 关于 origin 和它的周边 —— Git 远程仓库高级操作
        • 1. 推送主分支
        • 2. 合并远程仓库
        • 3. 远程追踪
        • 4. git push 的参数
        • 5. git push 的参数2
        • 6.git fetch 的参数
        • 7.没有 source 的 source
        • 8. git pull 的参数
  • Java
  • 版本控制
Kevin
2023-09-04
目录

版本控制指南

# learn git branch

练习网址: https://learngitbranching.js.org/?locale=zh_CN

# 主要

# 基础篇

# 1. git commit

Git 仓库中的提交记录保存的是你的目录下所有文件的快照,就像是把整个目录复制,然后再粘贴一样,但比复制粘贴优雅许多!

Git 希望提交记录尽可能地轻量,因此在你每次进行提交时,它并不会盲目地复制整个目录。条件允许的情况下,它会将当前版本与仓库中的上一个版本进行对比,并把所有的差异打包到一起作为一个提交记录。

Git 还保存了提交的历史记录。这也是为什么大多数提交记录的上面都有父节点的原因 —— 我们会在图示中用箭头来表示这种关系。对于项目组的成员来说,维护提交历史对大家都有好处。

关于提交记录太深入的东西咱们就不再继续探讨了,现在你可以把提交记录看作是项目的快照。提交记录非常轻量,可以快速地在这些提交记录之间切换!

# 2. git branch

Git 的分支也非常轻量。它们只是简单地指向某个提交纪录 —— 仅此而已。所以许多 Git 爱好者传颂:

早建分支!多用分支!
1

这是因为即使创建再多的分支也不会造成储存或内存上的开销,并且按逻辑分解工作到不同的分支要比维护那些特别臃肿的分支简单多了。

在将分支和提交记录结合起来后,我们会看到两者如何协作。现在只要记住使用分支其实就相当于在说:“我想基于这个提交以及它所有的父提交进行新的工作。”

image-20201210232420768

image-20201210232437569

# 3. git merge

git branch bugFix
git checkout bugFix
git commit
git checout master 
git commit 
git merge bugFix

1
2
3
4
5
6
7

# 4. git rebase

git checkout -b bugFix
git commit 
git checkout master
git commit
git checkout bugFix
git rebase master

1
2
3
4
5
6
7

# 4. git stash (暂存)

git stash save "message"
git stash apply stash@{0}
git  stash pop
git stash list
1
2
3
4

# 高级篇

# 1. 分离 HEAD

image-20201211002110713

image-20201211002520882

image-20201211002538723

image-20201211002552801

image-20201211002608090

image-20201211002618856

git checkout c4

1
2

# 2. 相对引用 (^)

image-20201211002927631

image-20201211003001377

image-20201211004515907

image-20201211004548677

image-20201211004604441

image-20201211004619504

image-20201211004631774

image-20201211004717741

git checout bugFix^
1

# 3.相对引用2(~)

image-20201211004852160

image-20201211004910153

image-20201211004922072

image-20201211004940550

image-20201211005014408

image-20201211005026256

image-20201211005040990

image-20201211005118479

git checkout HEAD~1
git branch -f master c6
git branch -f bugFix HEAD^

1
2
3
4

# 4.撤销变更

image-20201211010016262

image-20201211010031495

image-20201211010047584

image-20201211010105432

image-20201211010121200

image-20201211010138156

image-20201211010217592

git reset HEAD~1   // 或者git reset HEAD^
git checkout pushed
git revert HEAD

1
2
3
4

# 移动提交记录

# 1.Git Cherry-pick

image-20201211010819337

image-20201211010841766

image-20201211010904432

image-20201211010922807

image-20201211010939918

image-20201211011010094

git cherry-pick c3
git cherry-pick c4
git cherry-pick c7

1
2
3
4

# 2. 交互式 rebase

image-20201211011416487

image-20201211011438840

image-20201211011517254

image-20201211011544807

image-20201211011607143

image-20201211011637230

image-20201211011650236

image-20201211011732520

git rebase -i HEAD~4

1
2

image-20201211012659838

# 杂项

# 1. 只取一个提交记录

image-20201211012807981

image-20201211012934318

image-20201211012952052

image-20201211013026808

git rebase -i HEAD~3 // 不使用c3、c2
git branch -f master bugFix

## 或者
git checkout master
git cherry-pick bugFix // 或者git cherry-pick c4

1
2
3
4
5
6
7

# 2.提交的技巧 #1 -

image-20201211014513342

image-20201211014538446

image-20201211014727407

git rebase -i HEAD~2 #修改C2和C3的顺序
git commit --amend
git rebase -i HEAD~2 #修改C3'和C2''顺序
git branch -f master

1
2
3
4
5

# 3.提交的技巧 #2 -

image-20201211015138529

image-20201211015151870

image-20201211015215236

image-20201211015228444

image-20201211015305582

git checkout master
git cherry-pick newImage
git commit --amend
git cherry-pick caption

1
2
3
4
5

# 4.Git Tag

image-20201211015439718

image-20201211015449739

image-20201211015502091

image-20201211015514170

image-20201211015528739

image-20201211015551803

git tag v0 c1
git tag v1 c2
git checkout c2

1
2
3
4

# 5.Git Describe

image-20201211015733692

image-20201211015744638

image-20201211015755462

image-20201211015809574

image-20201211015823021

image-20201211015846527

git commit

1
2

# 高级话题

# 1. 多次 Rebase

image-20201211015934270

image-20201211020009312

git rebase master bugFix
git rebase bugFix side
git rebase side another
git branch -f master another

1
2
3
4
5

# 2. 两个父节点

image-20201211020237015

image-20201211020248720

image-20201211020302813

image-20201211020315730

image-20201211020328901

image-20201211020344173

image-20201211020401917

image-20201211020414141

image-20201211020427141

image-20201211020440421

image-20201211020503103

git branch bugWork HEAD~^2~

1
2

# 3. 纠缠不清的分支

image-20201211020556611

image-20201211020629390

git checkout one
git cherry-pick c4 c3 c2
git checkout two
git cherry-pick c5 c4 c3 c2
git branch -f three c2

1
2
3
4
5
6

image-20201211021043791

# 远程

# Push & Pull —— Git 远程仓库!

# 1. git clone

image-20201211021140372

image-20201211021152714

image-20201211021204277

image-20201211021216660

image-20201211021228698

image-20201211021247454

git clone 

1
2

# 2. 远程分支

image-20201211021340140

image-20201211021357397

image-20201211021409746

image-20201211021423180

image-20201211021436354

image-20201211021507102

git commit
git checkout o/master
git commit

1
2
3
4

# 3. git fetch

image-20201211021811221

image-20201211021823908

image-20201211021840060

image-20201211021851694

image-20201211021905907

image-20201211021917050

image-20201211021944598

git fetch

1
2

# 4. git pull

image-20201211022051558

image-20201211022103923

image-20201211022117652

image-20201211022133412

image-20201211022153523

image-20201211022216274

image-20201211022246078

git pull

1
2

# 5. 模拟团队合作

image-20201211022326182

image-20201211022340468

image-20201211022353573

image-20201211022407684

image-20201211022429021

image-20201211022445533

image-20201211022505941

git clone
git fakeTeamwork 2
git commit
git pull

1
2
3
4
5

# 6.git push

image-20201211023052199

image-20201211023103835

image-20201211023119318

image-20201211023146482

image-20201211023230718

git commit
git commit 
git push

1
2
3
4

# 7. 偏离的提交历史

image-20201211023321955

image-20201211023333122

image-20201211023345115

image-20201211023400637

image-20201211023410929

image-20201211023425932

image-20201211023444755

image-20201211023502202

image-20201211023516227

image-20201211023541375

image-20201211023557953

image-20201211023611299

image-20201211023634459

image-20201211023647355

image-20201211023711243

image-20201211023722467

image-20201211023745380

git clone
git fakeTeamwork 1
git commit
git pull --rebase
git push

1
2
3
4
5
6

# 8.锁定的Master(Locked Master)

image-20201211023956032

image-20201211024026705

image-20201211024038234

image-20201211024148125

git reset --hard o/master
git checkout -b feature C2
git push origin feature

1
2
3
4

# 关于 origin 和它的周边 —— Git 远程仓库高级操作

# 1. 推送主分支

image-20201211024546989

image-20201211024558674

image-20201211024621859

image-20201211024633570

image-20201211024700486

git fetch
git rebase o/master side1
git rebase side1 side2
git rebase side2 side3
git rebase side3 master
git push

1
2
3
4
5
6
7

# 2. 合并远程仓库

image-20201211024925048

image-20201211024944147

image-20201211024955872

image-20201211025021846

git checkout master
git pull origin master
git merge side1
git merge side2
git merge side3
git push origin master

1
2
3
4
5
6
7

# 3. 远程追踪

image-20201211025216029

image-20201211025227668

image-20201211025238864

image-20201211025248906

image-20201211025307793

image-20201211025319987

image-20201211025505235

image-20201211025518881

image-20201211025530418

image-20201211025549843

image-20201211025607841

image-20201211025636197

git checkout -b side o/master
git commit
git pull --rebase
git push

## 或者
git branch -f side o/master
git checkout side 
git commit
git pull --rebase
git push

1
2
3
4
5
6
7
8
9
10
11
12

# 4. git push 的参数

image-20201211031833199

image-20201211031845491

image-20201211031857754

image-20201211031914786

image-20201211031945194

image-20201211031959145

image-20201211032010178

image-20201211032029196

git push origin master
git push origin foo

1
2
3

# 5. git push 的参数2

image-20201211032141206

image-20201211032152297

image-20201211032204971

image-20201211032227065

image-20201211032240264

image-20201211032255426

image-20201211032306912

image-20201211032330005

git push origin foo:master
git push origin master^:foo

1
2
3

# 6.git fetch 的参数

image-20201211032723372

image-20201211032733768

image-20201211032748754

image-20201211032807227

image-20201211032820163

image-20201211032832038

image-20201211032844145

image-20201211032906387

image-20201211032918793

image-20201211032937575

image-20201211032949136

image-20201211033007186

image-20201211033019352

image-20201211033038092

git fetch origin master^:foo
git fetch origin foo:master
git checkout foo
git merge master

1
2
3
4
5

# 7.没有 source 的 source

image-20201211033206061

image-20201211033219810

image-20201211033232370

image-20201211033244992

image-20201211033258817

image-20201211033309998

image-20201211033330670

git pull origin :bar
git push origin :foo

1
2
3

# 8. git pull 的参数

image-20201211033500144

image-20201211033513994

image-20201211033527826

image-20201211033553449

image-20201211033607069

image-20201211033626397

image-20201211033642656

image-20201211033718539

git pull origin bar:foo
git pull origin master:side

1
2
3

image-20201211033832523

答案:http://element-ui.cn/article/show-70520.aspx

编辑 (opens new window)
上次更新: 2024/06/15, 15:12:25
Redis命令

← Redis命令

最近更新
01
04.Spring Boot 韩顺平
10-12
02
day14
08-29
03
day09
08-29
更多文章>
Theme by Vdoing | Copyright © 2019-2025 Evan Xu | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式