当前位置: 首页 > news >正文

github小记(一):清除github在add或者commit之后缓存区

github清除在add或者commit之后缓存区

  • 前言
  • 1. 第一步之后想要撤销
  • 2. 第二步之后想要撤销
    • a. 改变一下rrr.txt的内容
    • b. 想提交本地文件的test文件夹
    • c. 我后悔了突然不想提交了


前言

github自用

一般github上代码提交顺序:

第一步:

git add .
or
git add home/.../.../file_name
or
git add home/.../.../file_name -f

第二步:

git commit -m "test..."

第三步:

git push

1. 第一步之后想要撤销

使用git reset .命令

效果展示:

xxxxxx@server:~/xxxxxx/test_rm_cache$ git add test/1rrr.txt -f
xxxxxx@server:~/xxxxxx/test_rm_cache$ git status
On branch main
Your branch is up-to-date with 'origin/main'.Changes to be committed:(use "git restore --staged <file>..." to unstage)new file:   test/1rrr.txtxxxxxx@server:~/xxxxxx/test_rm_cache$ git reset .
xxxxxx@server:~/xxxxxx/test_rm_cache$ git status
On branch main
Your branch is up-to-date with 'origin/main'.nothing to commit, working tree clean

2. 第二步之后想要撤销

github的内容:
在这里插入图片描述
本地文件:
在这里插入图片描述

a. 改变一下rrr.txt的内容

xxxxxx@server:~/xxxxxx/test_rm_cache$ git add .
xxxxxx@server:~/xxxxxx/test_rm_cache$ git status
On branch main
Your branch is up-to-date with 'origin/main'.Changes to be committed:(use "git restore --staged <file>..." to unstage)modified:   rrr.txtxxxxxx@server:~/xxxxxx/test_rm_cache$ git commit -m "test1"
[main 6e51030] test11 file changed, 1 insertion(+)xxxxxx@server:~/xxxxxx/test_rm_cache$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 24 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 244 bytes | 244.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:ZisongXu/test_rm_cache.git942633e..6e51030  main -> main
xxxxxx@server:~/xxxxxx/test_rm_cache$

github内容:
在这里插入图片描述
本地文件:
在这里插入图片描述

b. 想提交本地文件的test文件夹

xxxxxx@server:~/xxxxxx/test_rm_cache$ git add test/1rrr.txt -f
xxxxxx@server:~/xxxxxx/test_rm_cache$ git status
On branch main
Your branch is up-to-date with 'origin/main'.Changes to be committed:(use "git restore --staged <file>..." to unstage)new file:   test/1rrr.txtxxxxxx@server:~/xxxxxx/test_rm_cache$ git commit -m "test2"
[main 9375ba3] test21 file changed, 2 insertions(+)create mode 100644 test/1rrr.txtxxxxxx@server:~/xxxxxx/test_rm_cache$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.(use "git push" to publish your local commits)nothing to commit, working tree clean
xxxxxx@server:~/xxxxxx/test_rm_cache$

c. 我后悔了突然不想提交了

xxxxxx@server:~/xxxxxx/test_rm_cache$ git reset HEAD~
xxxxxx@server:~/xxxxxx/test_rm_cache$ git reset --hard HEAD
HEAD is now at 6e51030 test1
sc19zx@server:~/apptainers/test_rm_cache$ git status
On branch main
Your branch is up-to-date with 'origin/main'.nothing to commit, working tree clean
xxxxxx@server:~/xxxxxx/test_rm_cache$ git push
Everything up-to-date
xxxxxx@server:~/xxxxxx/test_rm_cache$

github内容:
在这里插入图片描述
本地文件:
在这里插入图片描述

http://www.lryc.cn/news/190395.html

相关文章:

  • 【Debian系统】:安装debian系统之后,很多命令找不到,需要添加sudo之后才能使用,以下解决方法
  • 深入了解归并排序:原理、性能分析与 Java 实现
  • docker stop了一个docker exec容器,要怎么再启动呢
  • 【总结】kubernates 插件工具总结
  • RK3588平台产测之ArmSoM-W3 DDR带宽监控
  • 基于SpringBoot的作业管理系统设计与实现
  • TailwindCss Functions Directives
  • MDK自动生成带校验带SVN版本号的升级文件
  • 如何打造一个网络框架模块对接服务器
  • 装饰器模式和 AOP 面向切片编程(设计模式与开发实践 P15)
  • Git迁移新仓库并保存历史提交记录
  • MySql逗号分割的字段数据分解为多行
  • 共生与共享:线程与进程的关系
  • uniapp app或微信小程序项目使用gite仓库中的图片
  • KUKA机器人如何强制输出或取消数字IO信号?
  • 利用正则表达式进行数据采集和处理
  • javaScript:拖拽效果
  • 【Unity3D编辑器开发】Unity3D中制作一个可以随时查看键盘对应KeyCode值面板,方便开发
  • VUE echarts 柱状图、折线图 双Y轴 显示
  • Django开发之基础篇
  • 在 centos7 上安装Docker
  • 基于SpringBoot的大学城水电管理系统
  • 微信小程序 movable-view 控制长按才触发拖动 轻轻滑动页面正常滚动效果
  • mysql面试题27:数据库中间件了解过吗?什么是sharding jdbc、mycat,并且讲讲怎么使用?
  • DBCO Sata650,二苯并环辛烷Sata650,Seta-650-DBCO
  • JFLASH基本使用总结
  • 具身智能(Embodied AI)
  • C语言的文件写入、读取
  • CART 算法——决策树
  • CF1877A Goals of Victory