首页 > 其他分享 >git 版本穿梭

git 版本穿梭

时间:2023-07-31 17:34:10浏览次数:35  
标签:git demo 穿梭 code master 版本 commit shj

shj@MSI MINGW64 /d/code_lib/git-demo
$ git init
Initialized empty Git repository in D:/code_lib/git-demo/.git/

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ ll -a
total 5
drwxr-xr-x 1 shj 197121   0 Jul 31 17:04 ./
drwxr-xr-x 1 shj 197121   0 Jul 31 17:02 ../
drwxr-xr-x 1 shj 197121   0 Jul 31 17:04 .git/
-rw-r--r-- 1 shj 197121 248 Jul 31 17:03 hello.txt

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        hello.txt

nothing added to commit but untracked files present (use "git add" to t
rack)

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git add hello.txt

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   hello.txt


shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git commit -m "first commit" hello.txt
[master (root-commit) f9be8a9] first commit
 1 file changed, 10 insertions(+)
 create mode 100644 hello.txt

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reflog
f9be8a9 (HEAD -> master) HEAD@{0}: commit (initial): first commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git log\
> ^C

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git log
commit f9be8a93d5be82fb21941ff66ac23a9bd5ce9896 (HEAD -> master)
Author: shenhj <[email protected]>
Date:   Mon Jul 31 17:06:08 2023 +0800

    first commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch 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:   hello.txt

no changes added to commit (use "git add" and/or "git commit -a")

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git add hello.txt

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   hello.txt


shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git commit -m "second commit" hello.txt
[master e61dab7] second commit
 1 file changed, 1 insertion(+), 1 deletion(-)

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reflog
e61dab7 (HEAD -> master) HEAD@{0}: commit: second commit
f9be8a9 HEAD@{1}: commit (initial): first commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch 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:   hello.txt

no changes added to commit (use "git add" and/or "git commit -a")

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git add hello.txt

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git commit -m "third commit" hello.txt
[master bfde9da] third commit
 1 file changed, 1 insertion(+), 1 deletion(-)

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reflog
bfde9da (HEAD -> master) HEAD@{0}: commit: third commit
e61dab7 HEAD@{1}: commit: second commit
f9be8a9 HEAD@{2}: commit (initial): first commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git status
On branch master
nothing to commit, working tree clean

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reset --hard e61dab7
HEAD is now at e61dab7 second commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reflog
e61dab7 (HEAD -> master) HEAD@{0}: reset: moving to e61dab7
bfde9da HEAD@{1}: commit: third commit
e61dab7 (HEAD -> master) HEAD@{2}: commit: second commit
f9be8a9 HEAD@{3}: commit (initial): first commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reset --hard f9be8a9
HEAD is now at f9be8a9 first commit

shj@MSI MINGW64 /d/code_lib/git-demo (master)
$ git reflog
f9be8a9 (HEAD -> master) HEAD@{0}: reset: moving to f9be8a9
e61dab7 HEAD@{1}: reset: moving to e61dab7
bfde9da HEAD@{2}: commit: third commit
e61dab7 HEAD@{3}: commit: second commit
f9be8a9 (HEAD -> master) HEAD@{4}: commit (initial): first commit


shj@MSI MINGW64 /d/code_lib/git-demo (master)

 

1.命令解析

git init :初始化,生成  .git文件

git status:查看状态

git add  <文件名>:将文件从工作区添加到暂存区

git commit -m "first commit" <文件名>:将文件从暂存区添加到本地库

git reflog:查看提交日志信息

git log:查看详细提交日志信息

git reset --hard <版本号>:恢复历史版本

2.版本管理原理

指针

 

 3.内存管理

工作区(电脑中存放代码)----》暂存区----》本地库----》远程库

标签:git,demo,穿梭,code,master,版本,commit,shj
From: https://www.cnblogs.com/cxacswx/p/17593994.html

相关文章

  • git命令
     学习git命令前,我们可以先学习下git的基本流程  step1: remoterepositroy--(fetch/clone)-->localrepositroystep2: remoterepositroy--(pull)-->workspacestep3: workspace--(add)-->stagingarea,localrepositroycheckoutworkspace,没......
  • idea - 在setting 关闭 git Analyze code后 push 时自动开启 - 解决
    不要在setting里修改,需要在 这个齿轮中修改才生效 就这么奇怪 ......
  • github学习笔记(九):分支管理策略
    合并的分支到底是如何管理的呢?分支的合并通常git使用Fastforward模式来合并分支,但是这种模式下一旦删除分支,信息也随之消失。如果强制禁用FastForward模式,git就会在merge时生成一个新分支,这样从分支历史上就可以看出分支信息。例子创建并切换分支、修改文件、提交新的com......
  • 【wordpress开发必备】新增必填字段相关函数和钩子,适用6.1版本
    当表单包含多个必填字段时,它们的标签可能带有一个带有图例的星号,以说明这些字段是必填的。为了减少代码重复并帮助维护全局一致的标记,WordPress有两个新函数:wp_required_field_indicator()和wp_required_field_message()。如果主题和插件至少需要 WordPress6.1,它们也可以使用这......
  • IDEA,Pycharm,Goland,Webstorm 最新发布2023.2版本,亲测好用!
    期待已久的IntelliJIDEA2023.2终于正式发布了,同时发布的还有Pycharm,Goland,Webstorm等。具体的改变相信大家已经提前有所了解的了,我迫不及待的就下载体验了下,UI变好看了,使用起来感觉更流畅,好用推荐!IDEA2023.2最新版激活成功如下GoLand2023.2最新版激活成功如下......
  • JDK 版本异常导致 flutter doctor --android-licenses 出错 (class file version 61.0
    flutterdoctor--android-licensesError:AJNIerrorhasoccurred,pleasecheckyourinstallationandtryagainExceptioninthread"main"java.lang.UnsupportedClassVersionError:com/android/sdklib/tool/sdkmanager/SdkManagerClihasbeencompil......
  • X86架构CPU下Ubuntu系统环境源码编译pytorch-gpu-2.0.1版本
    本文操作步骤与aarch64架构CPU下Ubuntu系统环境源码编译pytorch-gpu-2.0.1版本大致相同,只是CPU架构不同而已,因此这里只记录不同的地方。 重点:一个个人心得,那就是要编译pytorch源码最好是选择docker环境,因为这种环境下配置比较纯净,一定要避免那种自己使用多年的Linux系统,那种......
  • git branch 分支信息显示
    默认显示分支信息:gitlog最新提交的在上面。1.正序,最新提交的在下面:gitlog--reverse2.倒序,显示分支信息gitreflogaa_null1b8582fcommit:提交产生的IDaa_null:提交分支@{1}:排序,加上--date参数就是commit时间。(git--date常用参数【汇总】)commit......
  • centos更换java版本
    以java11为例先使用下面的命令下载java11$sudoyum-yinstalljava-11-openjdk-devel输入命令改变java环境$sudoalternatives--configjava出现下面的界面,选择3(假如需要换为java11) 输入java-version查看版本 ......
  • vins-Fusion编译中有关opencv版本的问题
    一个一个修改文件就可以了(哭)https://zhuanlan.zhihu.com/p/548140724#:~:text=%2Fhome%2Fubuntu%2Fcatkin_ws%2Fsrc%2FVINS-Mono%2Fcamera_model%2Fsrc%2Fchessboard%2FChessboard.cc%3A20%3A38%3A%20error%3A%20%E2%80%98CV_GRAY2BGR%E2%80%99%20was%20not%20declared%20in%20th......