语法

Git分三个区

工作区----(add)--->暂存区----(commit)--->本地版本库----(push)---->远程版本库

工作区的取消

git restore 文件名字

暂存区git add .  后的取消  

git restore --staged  PHPInterview/2.strpos.php

本地版本库git commit  后的取消  

$ git log -2   选择倒数第二个
$ git reset --soft ec9bf0be9942e9f17e0431bd88c2737622353154

远程版本库git push后的   

$ git log -2   选择倒数第二个
$ git reset --hard ec9bf0be9942e9f17e0431bd88c2737622353154
此处不可git pull
$ git push  --force

工作区例子


Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.Changes not staged for commit:(use "git add <file>..." to update what will be committed)(use "git restore <file>..." to discard changes in working directory)modified:   PHPInterview/2.strpos.phpno changes added to commit (use "git add" and/or "git commit -a")Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git restore  PHPInterview/2.strpos.phpAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.nothing to commit, working tree cleanAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)

暂存区例子

Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.Changes to be committed:(use "git restore --staged <file>..." to unstage)modified:   PHPInterview/2.strpos.phpAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git restore --staged  PHPInterview/2.strpos.phpAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.Changes not staged for commit:(use "git add <file>..." to update what will be committed)(use "git restore <file>..." to discard changes in working directory)modified:   PHPInterview/2.strpos.phpno changes added to commit (use "git add" and/or "git commit -a")

本地版本库例子


Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.(use "git push" to publish your local commits)nothing to commit, working tree cleanAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git log -2
commit 45ce87d9ce1505a11a7f67a61e0c4acfa950a972 (HEAD -> master)
Author: 7117 <qinglangsalaheiyou@163.com>
Date:   Fri Nov 13 11:16:40 2020 +0800echocommit ec9bf0be9942e9f17e0431bd88c2737622353154 (origin/master)
Author: 7117 <qinglangsalaheiyou@163.com>
Date:   Tue Oct 27 13:07:57 2020 +08001Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git reset --soft ec9bf0be9942e9f17e0431bd88c2737622353154Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.Changes to be committed:(use "git restore --staged <file>..." to unstage)modified:   PHPInterview/2.strpos.php

远程版本库回退例子

$ git log -2
commit 30f126a4a49c6036444e6fee7fdc6d0fe45f58f7 (HEAD -> master, origin/master)
Author: 7117 <qinglangsalaheiyou@163.com>
Date:   Fri Nov 13 11:18:51 2020 +0800echo 2commit ec9bf0be9942e9f17e0431bd88c2737622353154
Author: 7117 <qinglangsalaheiyou@163.com>
Date:   Tue Oct 27 13:07:57 2020 +08001Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git reset --hard ec9bf0be9942e9f17e0431bd88c2737622353154
HEAD is now at ec9bf0b 1Administrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git status
On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.(use "git pull" to update your local branch)nothing to commit, working tree cleanAdministrator@Jim MINGW64 /d/phpstudy/PHPTutorial/WWW/PHPCollection (master)
$ git push --force
fatal: HttpRequestException encountered.▒▒▒▒▒▒▒▒ʱ▒▒▒▒
Total 0 (delta 0), reused 0 (delta 0)
remote: This repository moved. Please use the new location:
remote:   https://github.com/7117/phpCollection.git
remote:
remote: GitHub found 4 vulnerabilities on 7117/phpCollection's default branch (2 high, 2 low). To find out more, visit:
remote:      https://github.com/7117/phpCollection/network/alerts
remote:
To https://github.com/7117/CodePractice+ 30f126a...ec9bf0b master -> master (forced update)

Git各区的添加与撤销[实际操作验证]相关推荐

  1. git 撤销 add .操作

    不小心把不该同步的文件add进去了 撤销add操作 git reset HEAD . 就可以把工作区Unstaged 了

  2. GIT 新手入门-4种撤销操作

    一.git撤销未add的更改 原理:git checkout -- README.md拉取暂存区or版本库文件,并将其替换成工作区文件 撤销工作区已经修改的某一个文件         $ git ch ...

  3. GIT 撤销revert操作

    撤销commit version 92581提交记录 git revert [version:92581] : 对应commit version 04121502当合并分支时会把revert的代码不会 ...

  4. Git如何撤销merge操作

    Git如何撤销merge操作.当 merge 以后还有别的操作和改动时,用 git revert:该命令就是为撤销某次提交而存在的: 首先,我是明白100047dcc这次提交是有问题的,这是问题的源头 ...

  5. g-git 相关命令 及其 基本原理探索(二):git 在工作中的常用命令操作 ,超级实用!!!

    上一篇git 基本原理对git的使用以及文件分布已经有了一个整体的了解. 本篇将对工作中常用的一些git 操作命令的操作进行总结归纳,方便今后查阅. 文章目录 1. 分离头指针 2. 通过HEAD 来 ...

  6. 【Git笔记3】关于撤销、删除、恢复的那些事儿

    在跻身于"国庆抢票大战"的我们,不要忘记学习,今天接着上篇 [Git笔记2]必知习惯和如何版本回退,继续开干!一起来瞅瞅如何撤销没有add的修改,如何撤销以及add到暂存区的修改, ...

  7. git修改服务器的命令行,Git版本控制工具安装及命令行操作

    很多小伙伴不知道如何来安装Git版本控制工具,对于命令操作比较陌生.本文做了一个详细的文档,希望对大家有所帮助. 1.git 是什么一个分布式版本控制系统,和SVN类似,但远比SVN强大的一个版本控制 ...

  8. [超详细] Git 远程仓库及回滚日志操作

    一.远程仓库基本操作 1.拿到仓库地址(以GitEE为例): 2.初始化Git: 使用命令:git init 在准备存放的文件夹里使用命令git init进行初始化,也就是把这个文件夹变成git专属文 ...

  9. git mr 怎样合并部分_系统掌握Git之—分离头指针与合并操作

    分离头指针 分离头指针表示我们在工作在没用分支的情况下,我们通过git log 打印日志,选择中间的一个commitId,然后进行checkout操作,git checkout 82fdac4baac ...

最新文章

  1. Linux下安装Oracle参数自动初始化脚本
  2. linux 源码安装 yum rpm区别
  3. matlab 数学库,matlab数学函数库
  4. 使用Qt作窗口截屏(含源码)
  5. sellhis股票平面图
  6. 在 Google Earth 上看新闻
  7. php的mktime,PHP mktime()函数获得本地时间戳
  8. 自学python免费教材-python零基础自学教材
  9. Onvif协议:什么是Onvif
  10. px和毫米的换算_px和厘米怎么换算?
  11. 小程序css 如何引用图片,微信小程序实例:如何引入外部js的文件(图文)
  12. ubuntu处理视频 将视频转换成图片帧
  13. 确定你的台式计算机支持的内存类型,如何区分内存类型及查看内存的兼容性
  14. 微吼直播 html5,微吼直播jssdk接入指引.pdf
  15. shape (0,) 是什么意思
  16. 区块链中的“双花”问题
  17. mysql实现俩个属性加减运算_mysql加减乘除
  18. linux 命令总结大全
  19. 了解Intel IPP
  20. 移动端APP闪退的主要原因总结

热门文章

  1. NetBean中的使用,比如快捷键
  2. Scikit-learn数据预处理分类变量编码之字段特征编码
  3. java严格模式_“use strict” 严格模式使用(前端基础系列)
  4. OpenCV学习笔记之扫描图像
  5. windows7+visual studio 2013+CUDA7.5 编译caffe+配置matcaffe+配置pycaffe
  6. 开发函数计算的正确姿势 —— 移植 next.js 服务端渲染框架
  7. 高可用高性能分布式文件系统FastDFS实践Java程序
  8. 资源大集中 浪潮I9000刀片为国家税务总局打造全能型平台
  9. 自问自答 学习系列(1):从图像分类,到损失函数,到神经网络
  10. Windows内存的一些知识点