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

推荐订阅源

Google DeepMind News
Google DeepMind News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 【当耐特】
博客园_首页
博客园 - Franky
有赞技术团队
有赞技术团队
T
The Blog of Author Tim Ferriss
Recorded Future
Recorded Future
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
T
Tailwind CSS Blog
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
D
Docker
H
Help Net Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
S
SegmentFault 最新的问题
腾讯CDC
Latest news
Latest news
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
I
InfoQ
美团技术团队
C
Cybersecurity and Infrastructure Security Agency CISA
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
V
Visual Studio Blog
C
Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
T
Threat Research - Cisco Blogs
F
Full Disclosure
T
Threatpost
T
Tenable Blog
AWS News Blog
AWS News Blog
Cloudbric
Cloudbric
The Last Watchdog
The Last Watchdog
B
Blog RSS Feed
W
WeLiveSecurity
I
Intezer
月光博客
月光博客
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
L
Lohrmann on Cybersecurity
Hacker News - Newest:
Hacker News - Newest: "LLM"

Sunshine

SpringBoot定时任务@Scheduled注解详解 | Sunshine 大端模式、小端模式解析 | Sunshine 机器数、原码、反码、补码解析 | Sunshine Spring事件驱动模型实践 | Sunshine IDEA好用的几款插件 | Sunshine Linux使用yum安装MySQL详细步骤(CentOS7.3) | Sunshine Windows下MySQL解压版安装配置详细步骤 | Sunshine Java使用JDBC连接SQLServer数据库(二) | Sunshine Java使用JDBC连接SQLServer数据库(一) | Sunshine Oracle序列创建和使用 | Sunshine Git批量清理本地分支 | Sunshine Statement.RETURN_GENERATED_KEYS获取自增id踩坑记录 | Sunshine GitPages+Hexo搭建个人博客 | Sunshine
Git基本操作整理 | Sunshine
DongyangHu · 2019-11-29 · via Sunshine

基本命令

  • 初始化一个Git仓库:git init
  • 添加文件到暂存区:git add <file>
  • 删除文件:git rm <file>
  • 提交:git commit -m <message>
  • 工作区状态:git status
  • 查看有无修改:git diff <file>
  • 查看提交历史:git log
  • 查看命令历史:git reflow

版本回退

HEAD表示当前版本,HEAD^表示上一版本,HEAD^^表示上上个版本,HEAD~100表示上100个版本

  • 退回上一个版本:git reset --hard HEAD^
  • 通过版本好回退:git reset --hard commit_id

撤销修改

  • 丢弃工作区的修改:git checkout -- file
  • 工作区进行了修改,并且添加到了暂存区时,想丢弃修改,分两步。第一步用命令git reset HEAD <file>回到上述状态,再按上述描述操作

远程仓库

  • 添加关联一个远程库:git remote add origin git@server-name:path/repo-name.git
  • 关联后,使用命令git push -u origin
  • 推送某个分支的更新:push origin master
  • 克隆一个远程仓库:git clone <地址>

分支管理

  • 查看分支:git branch
  • 创建分支:git branch <name>
  • 切换分支:git checkout <name>
  • 创建+切换分支:git checkout -b <name>
  • 合并某分支到当前分支:git merge <name>
  • 分支合并图:git log --graph
  • 删除分支:git branch -d <name>
  • 保存当前工作现场:git stash
  • 查看保存的工作现场列表:git stash list
  • 恢复:
    • git stash apply恢复,但是恢复后,stash内容不会删除,需要用git stash drop来删除
    • git stash pop,恢复时会删除stash的内容
    • 恢复指定的stash:git stash apply stash@{序号}
  • 强制删除没有合并过的分支:git branch -D <name>

多人协作常见场景

  • git push origin <branch-name>推送自己的修改;
  • 如果远程分支相较于本地更新,需要先用git pull尝试进行合并;
  • 如果合并存在冲突,则手动解决冲突,并在本地提交;
  • 没有冲突或者解决掉冲突后,重新用git push origin <branch-name>推送就能成功;
  • 使用git pull时提示no tracking information,则说明本地分支和远程分支的链接关系没有创建,用命令git branch --set-upstream-to <branch-name> origin/<branch-name>

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Sunshine