My_diary/Operation Log.md

251 lines
6.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

+ 检查当前文件路径的文件
```shell
C:\Users\Lei Zhao\Desktop\demo>dir
驱动器 C 中的卷没有标签。
卷的序列号是 0E23-B25F
C:\Users\Lei Zhao\Desktop\demo 的目录
2024/11/29 12:45 <DIR> .
2024/11/29 12:43 <DIR> ..
2024/11/29 12:43 39 info.txt
2024/11/29 12:45 9 README.md
2024/11/14 16:35 19,456 家委会竞选申报表.doc
3 个文件 19,504 字节
2 个目录 74,087,919,616 可用字节
```
+ 初始化当前目录
```
C:\Users\Lei Zhao\Desktop\demo>git init
Initialized empty Git repository in C:/Users/Lei Zhao/Desktop/demo/.git/
C:\Users\Lei Zhao\Desktop\demo>git checkout -b main
Switched to a new branch 'main'
```
+ 添加当前所有文件;提交一次说明
```shell
C:\Users\Lei Zhao\Desktop\demo>git add .
C:\Users\Lei Zhao\Desktop\demo>git commit -m "my first demo about git on my home pc"
[main (root-commit) 5ae0a01] my first demo about git on my home pc
3 files changed, 2 insertions(+)
create mode 100644 README.md
create mode 100644 info.txt
create mode 100644 "\345\256\266\345\247\224\344\274\232\347\253\236\351\200\211\347\224\263\346\212\245\350\241\250.doc"
```
+ 配置远端仓库;推送当前分支
```shell
C:\Users\Lei Zhao\Desktop\demo>git remote add origin https://demo.gitea.com/lzdev/Demo.git
C:\Users\Lei Zhao\Desktop\demo>git push -u origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (5/5), 5.06 KiB | 1.69 MiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: . Processing 1 references
remote: Processed 1 references in total
To https://demo.gitea.com/lzdev/Demo.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
```
* 配置用户
```shell
C:\Users\Lei Zhao\Desktop\demo>git config --global user.name "lzdev"
C:\Users\Lei Zhao\Desktop\demo>git config --global user.email "ciozhao@126.com"
```
+ 提交一次说明
```shell
C:\Users\Lei Zhao\Desktop\demo>git commit -m "a first change about README.md"
On branch main
Your branch is up to date with 'origin/main'.
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: README.md
no changes added to commit (use "git add" and/or "git commit -a")
```
+ 添加一个新文件监控;提交关于这事件的说明
```shell
C:\Users\Lei Zhao\Desktop\demo>git add README.md
C:\Users\Lei Zhao\Desktop\demo>git commit -m "a first change about README.md"
[main 4c393c2] a first change about README.md
1 file changed, 8 insertions(+), 1 deletion(-)
C:\Users\Lei Zhao\Desktop\demo>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
```
+ 查看log
```shell
C:\Users\Lei Zhao\Desktop\demo>git log
commit 4c393c2fb05ea7e2fd3b01844d1ceba2ab97fc66 (HEAD -> main)
Author: lzdev <ciozhao@126.com>
Date: Fri Nov 29 12:57:06 2024 +0800
a first change about README.md
commit 5ae0a0130741c9015dae69f05c95e5380dd19f17 (origin/main)
Author: lzdev <ciozhao@126.com>
Date: Fri Nov 29 12:46:21 2024 +0800
my first demo about git on my home pc
```
+ 缩略检查log
```shell
+ 方法一
C:\Users\Lei Zhao\Desktop\demo>git log --pretty=oneline
4c393c2fb05ea7e2fd3b01844d1ceba2ab97fc66 (HEAD -> main) a first change about README.md
5ae0a0130741c9015dae69f05c95e5380dd19f17 (origin/main) my first demo about git on my home pc
+ 方法二
C:\Users\Lei Zhao\Desktop\demo>git log --graph --pretty=oneline --abbrev-commit
* 4c393c2 (HEAD -> main) a first change about README.md
* 5ae0a01 (origin/main) my first demo about git on my home pc
```
* 查看所有信息
```shell
C:\Users\Lei Zhao\Desktop\demo>git show
commit 4c393c2fb05ea7e2fd3b01844d1ceba2ab97fc66 (HEAD -> main)
Author: lzdev <ciozhao@126.com>
Date: Fri Nov 29 12:57:06 2024 +0800
a first change about README.md
diff --git a/README.md b/README.md
index f73693a..4edd251 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,8 @@
-"test"
+### 关于这个项目的说明
+
+作者Lao Zhao 日期2024年11月29日
+
+---
+
++ 今天创建了这个账号
++ 准备用来记录日记也不错
\ No newline at end of file
```
+ 推送当前版本
```shell
C:\Users\Lei Zhao\Desktop\demo>git push -u origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 490 bytes | 490.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: . Processing 1 references
remote: Processed 1 references in total
To https://demo.gitea.com/lzdev/Demo.git
5ae0a01..4c393c2 main -> main
branch 'main' set up to track 'origin/main'.
```
+ 监视当前目录所有文件并显示信息
```shell
C:\Users\Lei Zhao\Desktop\demo>git add .
C:\Users\Lei Zhao\Desktop\demo>git show
commit 4c393c2fb05ea7e2fd3b01844d1ceba2ab97fc66 (HEAD -> main, origin/main)
Author: lzdev <ciozhao@126.com>
Date: Fri Nov 29 12:57:06 2024 +0800
a first change about README.md
diff --git a/README.md b/README.md
index f73693a..4edd251 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,8 @@
-"test"
+### 关于这个项目的说明
+
+作者Lao Zhao 日期2024年11月29日
+
+---
+
++ 今天创建了这个账号
++ 准备用来记录日记也不错
\ No newline at end of file
```
+ 查看当前状态
```shell
C:\Users\Lei Zhao\Desktop\demo>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: README.md
deleted: info.txt
```
+ 因本地删除文件,需要检视信息里删除它的信息; 顺便提交一次说明
```shell
C:\Users\Lei Zhao\Desktop\demo>git rm info.txt
fatal: pathspec 'info.txt' did not match any files
C:\Users\Lei Zhao\Desktop\demo>git commit -m "我删除了一个叫info.txt的文件"
[main da56802] 我删除了一个叫info.txt的文件
2 files changed, 4 insertions(+), 3 deletions(-)
delete mode 100644 info.txt
```
+ 推送
```shell
C:\Users\Lei Zhao\Desktop\demo>git push
warning: redirecting to https://demo.gitea.com/lzdev/My_diary/
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 529 bytes | 529.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: . Processing 1 references
remote: Processed 1 references in total
To https://demo.gitea.com/lzdev/Demo.git
4c393c2..da56802 main -> main
```