惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threat Research - Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
V
Vulnerabilities – Threatpost
GbyAI
GbyAI
P
Proofpoint News Feed
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
A
About on SuperTechFans
T
Tenable Blog
M
MIT News - Artificial intelligence
IT之家
IT之家
I
Intezer
D
DataBreaches.Net
爱范儿
爱范儿
T
Threatpost
C
CERT Recently Published Vulnerability Notes
云风的 BLOG
云风的 BLOG
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
K
Kaspersky official blog
大猫的无限游戏
大猫的无限游戏
A
Arctic Wolf
Y
Y Combinator Blog
Cyberwarzone
Cyberwarzone
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security
H
Help Net Security
Microsoft Security Blog
Microsoft Security Blog
Spread Privacy
Spread Privacy
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AWS News Blog
AWS News Blog
博客园 - 聂微东
C
Check Point Blog
S
Securelist
有赞技术团队
有赞技术团队
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
Last Week in AI
Last Week in AI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
G
GRAHAM CLULEY
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
L
Lohrmann on Cybersecurity
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog

博客园 - Mr.peter

git常用命令汇总 Golang基础面试题 ansible是什么?怎么玩?给出常问的面试题和答案 Terraform telnet localhost 3306 -bash: telnet: command not found macos 开放3306端口 curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused Error: git: Failed to download resource "git.rb" Mysql 授予root在任意主机访问数据库的权限 使用Redis来处理高并发问题 go slice切片的扩容机制是什么? 使用Kubernetes时可以采取哪些最佳安全措施 Kubernetes与Docker Swarm的区别如何 k8s是怎么进行服务注册的 说说你对Job这种资源对象的了解 常用的标签分类有哪些 简述Helm及其优势 简述Kubernetes集群联邦 简述Kubernetes中,如何使用EFK实现日志的统一管理 Kubernetes 网络 Kubernetes PodSecurityPolicy
Git 全量终极速记表
Mr.peter · 2026-03-14 · via 博客园 - Mr.peter

一、基础仓库命令

  1. 本地初始化仓库 git init
  2. 服务器创建裸仓库 git init --bare
  3. 查看远程仓库地址 git remote -v

二、分支操作(最常用)

  1. 查看所有分支 git branch
  2. 新建并切换分支 git checkout -b 分支名
  3. 删除本地分支 git branch -d 分支名
  4. 切换分支 git checkout 分支名

三、代码提交流程(标准流程)

  1. 查看文件修改状态 git status
  2. 添加到暂存区 git add 文件名git add .
  3. 提交到本地仓库 git commit -m "提交信息"
  4. 推送到远程仓库 git push

四、第一次推送分支(必背!)

本地分支第一次推远程,必须绑定上游

git push -u origin 分支名

-u = 绑定关系,以后直接 git push 即可


五、拉取代码(pull vs fetch)

  1. 拉取并自动合并 git pull = git fetch + git merge
  2. 只拉取不合并(安全) git fetch

六、暂存代码(写一半切分支)

  1. 临时储藏代码 git stash
  2. 储藏并加备注 git stash push -m "备注"
  3. 查看所有储藏 git stash list
  4. 恢复储藏并删除 git stash pop

七、撤销 / 回滚(你的薄弱点!重点背)

1)还没 add(工作区)

撤销修改,恢复上次提交

git checkout -- 文件名

2)已经 add(暂存区)

3)已经 commit(未 push)

  • 回退提交,但代码保留 git reset --soft 提交ID
  • 回退提交,代码直接删除(危险) git reset --hard 提交ID

4)已经 push 到远程(公共分支)

安全撤销,不破坏历史

git revert 提交ID


八、合并分支(merge vs rebase)

  1. git merge 保留所有历史,安全,公共分支用
  2. git rebase 历史变成一条直线,干净,自己私有分支用洁癖专用、细节控专用绝对不能在公共分支用

九、Tag 版本发布(上线用)

  1. 打版本标签 git tag v1.0.0
  2. 推送到远程 git push origin v1.0.0
  3. git push 默认不推 tag,必须单独推

十、冲突处理

  1. 手动修改文件,解决冲突
  2. git add
  3. git commit
  4. git push

十一、最易混淆对比(你的薄弱点)

✅ git add vs git stash

  • git add:正常提交,进入暂存区
  • git stash:代码写一半,临时藏起来

✅ git checkout -- 文件名 vs git reset

  • checkout --:撤销工作区(未 add)
  • reset:撤销暂存区回退提交

✅ reset --soft vs --hard

  • --soft:回退提交,代码保留
  • --hard:回退提交,代码删除

✅ merge vs rebase

  • merge:安全,保留历史,公共分支用
  • rebase:干净直线,私有分支用

posted @ 2026-03-14 18:00  Mr.peter  阅读(13)  评论()    收藏  举报