<commit_before>***********************************************************************************************
                        本地机器配置github帐号
***********************************************************************************************

1 ------------- 设置邮箱，用户名 ---------------
 在本地建立一个文件夹，然后做一些全局变量的初始化

git config --global user.name = "用户名或者用户ID"

git config --global user.email = "邮箱"

zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git config --global user.email "<EMAIL>"
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git config --global user.name "zhoulpg"


这两个选项会在以后的使用过程中自动添加到代码中。

2 ------------------------------------------
创建验证用的公钥
这个是比较复杂和困扰大多数人的地方，因为 git 是通过 ssh 的方式访问资源库的，所以需要在本地创建验证用的文件。

使用命令：ssh-keygen -C 'you email <EMAIL>' -t rsa

会在用户目录 ~/.ssh/ 下建立相应的密钥文件

可以使用 ssh -v git@github.com 命令来测试链接是否畅通
3 ------------在github网站 Setting --> SSH keys 添加创建的公共密钥
上传公钥
在 github.com 的界面中 选择右上角的 Account Settings，然后选择 SSH Public Keys ，选择新加。

Title 可以随便命名，Key 的内容拷贝自 ~/.ssh/id_rsa.pub 中的内容，
完成后，可以再使用 ssh -v git@github.com 进行测试。看到下面的信息表示验证成功。

4 ------------  ssh -v git@github.com 命令测试是否成功，显示下面的信息， 标示成功了
zhoulp@zhoulp-desktop:/data2/workshop/github$  ssh -v git@github.com
OpenSSH_5.3p1 Debian-3ubuntu7.1, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [172.16.31.10] port 22.
debug1: Connection established.
debug1: identity file /home/zhoulp/.ssh/identity type -1
debug1: identity file /home/zhoulp/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/zhoulp/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
The authenticity of host 'github.com (172.16.31.10)' can't be established.
RSA key fingerprint is fc00:e968:6179::de52:7100:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,172.16.31.10' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/zhoulp/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.utf8
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi zhoulipeng! You've successfully authenticated, but GitHub does not provide shell access.
                                                                                           debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 2648, received 2008 bytes, in 0.8 seconds
Bytes per second: sent 3492.7, received 2648.6
debug1: Exit status 1






三/ 提交一个文件到  github 
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ touch firstcommit.txt
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git add firstcommit.txt 
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$  git commit -o firstcommit.txt  -m "commit strings dir"
[master 9cc5a71] commit strings dir
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 firstcommit.txt
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git remote add origin <EMAIL>:zhoulipeng/clibs.git
fatal: 远程 origin 已经存在。
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git remote add mywork <EMAIL>:zhoulipeng/clibs.git
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git push -u mywork master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 277 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To <EMAIL>:zhoulipeng/clibs.git
   633dc5c..9cc5a71  master -> master
分支 master 设置为跟踪来自 mywork 的远程分支 master。

四
// 如果makefile 已经提交， 从新设置为未提交状态

git reset HEAD^1 Makefile<commit_msg>github如何回退，以及撤销回退<commit_after>***********************************************************************************************
                        本地机器配置github帐号
***********************************************************************************************

1 ------------- 设置邮箱，用户名 ---------------
 在本地建立一个文件夹，然后做一些全局变量的初始化

git config --global user.name = "用户名或者用户ID"

git config --global user.email = "邮箱"

zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git config --global user.email "<EMAIL>"
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git config --global user.name "zhoulpg"


这两个选项会在以后的使用过程中自动添加到代码中。

2 ------------------------------------------
创建验证用的公钥
这个是比较复杂和困扰大多数人的地方，因为 git 是通过 ssh 的方式访问资源库的，所以需要在本地创建验证用的文件。

使用命令：ssh-keygen -C 'you email <EMAIL>' -t rsa

会在用户目录 ~/.ssh/ 下建立相应的密钥文件

可以使用 ssh -v git@github.com 命令来测试链接是否畅通
3 ------------在github网站 Setting --> SSH keys 添加创建的公共密钥
上传公钥
在 github.com 的界面中 选择右上角的 Account Settings，然后选择 SSH Public Keys ，选择新加。

Title 可以随便命名，Key 的内容拷贝自 ~/.ssh/id_rsa.pub 中的内容，
完成后，可以再使用 ssh -v <EMAIL>@github.com 进行测试。看到下面的信息表示验证成功。

4 ------------  ssh -v <EMAIL>@github.com 命令测试是否成功，显示下面的信息， 标示成功了
zhoulp@zhoulp-desktop:/data2/workshop/github$  ssh -v <EMAIL>@github.com
OpenSSH_5.3p1 Debian-3ubuntu7.1, OpenSSL 0.9.8k 25 Mar 2009
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [172.16.31.10] port 22.
debug1: Connection established.
debug1: identity file /home/zhoulp/.ssh/identity type -1
debug1: identity file /home/zhoulp/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/zhoulp/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3p1 Debian-3ubuntu7.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
The authenticity of host 'github.com (172.16.31.10)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,172.16.31.10' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/zhoulp/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.utf8
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi zhoulipeng! You've successfully authenticated, but GitHub does not provide shell access.
                                                                                           debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 2648, received 2008 bytes, in 0.8 seconds
Bytes per second: sent 3492.7, received 2648.6
debug1: Exit status 1






三/ 提交一个文件到  github 
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ touch firstcommit.txt
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git add firstcommit.txt 
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$  git commit -o firstcommit.txt  -m "commit strings dir"
[master 9cc5a71] commit strings dir
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 firstcommit.txt
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git remote add origin <EMAIL>:zhoulipeng/clibs.git
fatal: 远程 origin 已经存在。
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git remote add mywork <EMAIL>:zhoulipeng/clibs.git
zhoulp@zhoulp-ThinkPad-T420:~/workshop/github/project1/clibs$ git push -u mywork master
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 277 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To <EMAIL>:zhoulipeng/clibs.git
   633dc5c..9cc5a71  master -> master
分支 master 设置为跟踪来自 mywork 的远程分支 master。

四
// 如果makefile 已经提交， 从新设置为未提交状态

git reset HEAD^1 Makefile


五
版本回退
在Git中，用HEAD表示当前版本，上一个版本就是HEAD^，上上一个版本就是HEAD^^，当然往上100个版本写100个^比较容易数不过来，所以写成HEAD~100。
git log // 查看提交的日志记录, 不包括会退的记录
git log --pretty=oneline // 提交日志精简
git reset --hard HEAD^ // 撤销修改， 回退到上一个版本

git reflog// 用来记录你的每一次命令， 即使是回退
git reset --hard 92ce730 //回到92ce730代表的修改状态。

zhoulp@zhoulp-desktop:/data2/workshop/github/cppwork$ git log --pretty=oneline
92ce730fbf36464ef7962a5fb3ed2de4d51bb73f add clock_gettime_gettimeofday
e6719a33ab66f89a22585c72dfb310775bfcfe59 提交测试cpu性能测试函数
42c77234018c44f2bc97eee4d4faf7c1b4f85f34 TODO 添加待做事项
46ba3ecba165215bbad3b1788acdc6488851b48d 提交可用的stunserver 服务器地址
5225ca6d8a640f0479b3315a04d90d5318756e94 添加TODO待做事项文档
c0889e8ee437b25afc0d6c37cd2a0929ea5c3549 完善 git 学习资料
cf5f306cb4780216233020419d4d7d387cbbc681 增加filelog目录， 存放自己写的文件日志代码
4766fbeac796638090a09507b5b7e36b5fd97bae 增加virtual: cpp 接口及继承， time 时间相关的测试代码
7b61639662661c7f0ddefd96ca2bc73a49b34d0d 提交filelog, time两个目录，filelog存放日志源码，time放时间相关处理函数
69643888bc3fdc3082f89e02fbf855d4ca2a5837 首次提交 filesystem:包含三个程序1. 检测LinuxU盘插入 2. 获取磁盘分区空间 3. 获取各分区磁盘设备挂载点
78dad030e45afb767f4401eaed637660e769a718 更新 git doc
393a84622de66519cdc1b9aa20d2080ad1d93186 提交learngitMy.txt , 该文档内容是记录一些git控制命令
6f37eaa94595e9cc7bf71d5070792597534043f1 commit dir:abstract  memory  print threadpool  tree
d08722b48343fb5b94a89513dfed61dedcb77d65 Initial commit
zhoulp@zhoulp-desktop:/data2/workshop/github/cppwork$ git reset --hard HEAD^
HEAD is now at e6719a3 提交测试cpu性能测试函数
zhoulp@zhoulp-desktop:/data2/workshop/github/cppwork$ git log --pretty=oneline
e6719a33ab66f89a22585c72dfb310775bfcfe59 提交测试cpu性能测试函数
42c77234018c44f2bc97eee4d4faf7c1b4f85f34 TODO 添加待做事项
46ba3ecba165215bbad3b1788acdc6488851b48d 提交可用的stunserver 服务器地址
5225ca6d8a640f0479b3315a04d90d5318756e94 添加TODO待做事项文档
c0889e8ee437b25afc0d6c37cd2a0929ea5c3549 完善 git 学习资料
cf5f306cb4780216233020419d4d7d387cbbc681 增加filelog目录， 存放自己写的文件日志代码
4766fbeac796638090a09507b5b7e36b5fd97bae 增加virtual: cpp 接口及继承， time 时间相关的测试代码
7b61639662661c7f0ddefd96ca2bc73a49b34d0d 提交filelog, time两个目录，filelog存放日志源码，time放时间相关处理函数
69643888bc3fdc3082f89e02fbf855d4ca2a5837 首次提交 filesystem:包含三个程序1. 检测LinuxU盘插入 2. 获取磁盘分区空间 3. 获取各分区磁盘设备挂载点
78dad030e45afb767f4401eaed637660e769a718 更新 git doc
393a84622de66519cdc1b9aa20d2080ad1d93186 提交learngitMy.txt , 该文档内容是记录一些git控制命令
6f37eaa94595e9cc7bf71d5070792597534043f1 commit dir:abstract  memory  print threadpool  tree
d08722b48343fb5b94a89513dfed61dedcb77d65 Initial commit


zhoulp@zhoulp-desktop:/data2/workshop/github/cppwork$ git reflog
e6719a3 HEAD@{0}: HEAD^: updating HEAD
92ce730 HEAD@{1}: commit: add clock_gettime_gettimeofday
e6719a3 HEAD@{2}: commit: 提交测试cpu性能测试函数
42c7723 HEAD@{3}: commit: TODO 添加待做事项
46ba3ec HEAD@{4}: commit: 提交可用的stunserver 服务器地址
5225ca6 HEAD@{5}: commit: 添加TODO待做事项文档
c0889e8 HEAD@{6}: commit: 完善 git 学习资料
cf5f306 HEAD@{7}: commit: 增加filelog目录， 存放自己写的文件日志代码
4766fbe HEAD@{8}: commit: 增加virtual: cpp 接口及继承， time 时间相关的测试代码
7b61639 HEAD@{9}: commit: 提交filelog, time两个目录，filelog存放日志源码，time放时间相关处理函数
6964388 HEAD@{10}: clone: from https://github.com/zhoulipeng/cppwork.git
zhoulp@zhoulp-desktop:/data2/workshop/github/cppwork$ git reset --hard 92ce730

{'fraction_non_alphanumeric': 0.12602008788449467, 'fraction_numerical': 0.10342121782799749, 'mean_word_length': 4.980760206475833, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 24, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 11, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3547039', 'n_tokens_mistral': 6212, 'n_tokens_neox': 5726, 'n_words': 1128}