这是我学习linux的过程,每天都会更新所学习的知识总结,每个例子都是我自己的亲手实践的,作为新人的我希望各位大佬提出宝贵的意见!!
编写一个learn.txt文件
[root@localhost reposiitory
]
The future is scary but you can’t just run to the past cause it’s familiar.
Success is the ability to go from one failure to another with no loss of enthusiasm.
[root@localhost reposiitory
]
[root@localhost reposiitory
]
[master(根提交) 10ed61a
] versions 1st
Committer: root
<root@localhost.localdomain
>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:
git config --global user.name
"Your Name"
git config --global user.email you@example.com
设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:
git commit --amend --reset-author
1
file changed, 2 insertions
(+
)
create mode 100644 learn.txt
[root@localhost reposiitory
]
The future is scary but you can’t just run to the past cause it’s familiar apple.
Success is the ability to go from one failure to another with no loss of enthusiasm
[root@localhost reposiitory
]
修改尚未加入提交(使用
"git add" 和/或
"git commit -a")
[root@localhost reposiitory
]
diff --git a/learn.txt b/learn.txt
index 8477435
..d58874e 100644
--- a/learn.txt
+++ b/learn.txt
@@ -1,2 +1,2 @@
-The future is scary but you can’t just run to the past cause it’s familiar.
+The future is scary but you can’t just run to the past cause it’s familiar apple.
Success is the ability to go from one failure to another with no loss of enthusiasm
将修改后的文件提交到仓库
[root@localhost reposiitory
]
[root@localhost reposiitory
]
[master a478b3a
] version 2nd
Committer: root
<root@localhost.localdomain
>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:
git config --global user.name
"Your Name"
git config --global user.email you@example.com
设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:
git commit --amend --reset-author
1
file changed, 1 insertion
(+
), 1 deletion
(-
)
[root@localhost reposiitory
]
无文件要提交,干净的工作区
版本回退
[root@localhost reposiitory
]
The future is scary but you can’t just run to the past cause it’s familiar apple.
Success is the ability to go from one failure to another with no loss of enthusiasm GPL.
[root@localhost reposiitory
]
[root@localhost reposiitory
]
[master e186dca
] versions GPL
Committer: root
<root@localhost.localdomain
>
您的姓名和邮件地址基于登录名和主机名进行了自动设置。请检查它们正确
与否。您可以通过下面的命令对其进行明确地设置以免再出现本提示信息:
git config --global user.name
"Your Name"
git config --global user.email you@example.com
设置完毕后,您可以用下面的命令来修正本次提交所使用的用户身份:
git commit --amend --reset-author
1
file changed, 1 insertion
(+
), 1 deletion
(-
)
[root@localhost reposiitory
]
commit e186dcac99f004c387c7ea33185488cce918d55b
Author: root
<root@localhost.localdomain
>
Date: Wed Oct 21 23:05:24 2020 +0800
versions GPL
commit a478b3a701fc92ddd70a2106961fa10816ea5b0b
Author: root
<root@localhost.localdomain
>
Date: Wed Oct 21 22:59:34 2020 +0800
version 2nd
commit 10ed61ad74688524329183b39bf7506289e3dad9
Author: root
<root@localhost.localdomain
>
Date: Wed Oct 21 22:42:47 2020 +0800
versions 1st
退回上一个版本
[root@localhost reposiitory
]
HEAD 现在位于 a478b3a version 2nd
[root@localhost reposiitory
]
The future is scary but you can’t just run to the past cause it’s familiar apple.
Success is the ability to go from one failure to another with no loss of enthusiasm
[root@localhost reposiitory
]
HEAD 现在位于 e186dca versions GPL
记录命令
当你你回退到了某个版本,关掉了电脑,第二天早上就后悔了,想恢复到新版本怎么办?找不到新版本的commit id怎么办? 就用git记录命令的命令 git reflog
[root@localhost reposiitory
]
e186dca HEAD@
{0
}: reset: moving to e186dcac99f004c387c7ea33185488cce918d55b
a478b3a HEAD@
{1
}: reset: moving to HEAD^
e186dca HEAD@
{2
}: commit: versions GPL
a478b3a HEAD@
{3
}: commit: version 2nd
10ed61a HEAD@
{4
}: commit
(initial
): versions 1st