标签:进阶 原因 git log sans 问题 exp title out client
本教程为学习笔记,github作为最受欢迎的资源库,不可不学!详细教程参见:廖雪峰的官方网站Git教程系列。准备花两篇幅搞定实战总结,闲言碎语少说,脚踏实地求真!
1,Git入门
1 Administrator@WIN-9S4D59CISAA MINGW64 ~(master) 2 $ git config --global user.name "zhangbc" 3 4 Administrator@WIN-9S4D59CISAA MINGW64 ~(master) 5 $ git config --global user.email "zhangbochengcheng189@163.com"
1 Administrator@WIN-9S4D59CISAA MINGW64 ~(master) 2 $ cd F: 3 4 Administrator@WIN-9S4D59CISAA MINGW64 /f 5 $ mkdir learngit 6 7 Administrator@WIN-9S4D59CISAA MINGW64 /f 8 $ cd learngit/ 9 10 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit 11 $ pwd 12 /f/learngit
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit 2 $ git init 3 Initialized empty Git repository in F:/learngit/.git/ 4 5 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 6 $
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git add readme.md 3 4 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 5 $ git commit -m "wrote a readme file." 6 [master (root-commit) a25e8e4] wrote a readme file. 7 1 file changed,42 insertions(+) 8 create mode 100644 readme.md
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git status 3 On branch master 4 Changes not staged for commit: 5 (use "git add <file>..." to update what will be committed) 6 (use "git checkout -- <file>..." to discard changes in working directory) 7 modified: readme.md 8 no changes added to commit (use "git add" and/or "git commit -a")
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git diff readme.md 3 diff --git a/readme.md b/readme.md 4 index 33a3876..46dd97d100644 5 --- a/readme.md 6 +++ b/readme.md 7 @@-40,3+40,6@@ 8 git提交到github: 9 ssh-keygen -C ‘zhangbocheng189@163.com’-t rsa 10 回到GitHub个人首页,点击AccountSettings-> SSH PublicKeys->Add another public key。title 可以随便取名字,Key里面添加的内容为 id_rsa.pub 文件内所有的代码。然后点击Apply即可。 11 + 12 +Git is a distributed version control system. 13 +Git is free software. 14 \ No newline at end of file
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git log 3 commit 6fa7dc43a0aa553ae0a3cf9b9a6c9b2757a8e556 4 Author: zhangbc <zhangbochengcheng189@163.com> 5 Date: Sun Mar 5 23:21:18 2017 +0800 6 wrote a readme file. 7 commit a25e8e46a364a39e52a36cec1bb94bf58921fae4 8 Author: zhangbc <zhangbochengcheng189@163.com> 9 Date: Sun Mar 5 23:07:56 2017 +0800 10 wrote a readme file.
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git log --pretty=oneline 3 6fa7dc43a0aa553ae0a3cf9b9a6c9b2757a8e556 wrote a readme file. 4 a25e8e46a364a39e52a36cec1bb94bf58921fae4 wrote a readme file.
HEAD
表示当前版本,也就是最新的提交3628164...882e1e0
(注意我的提交ID和你的肯定不一样),上一个版本就是HEAD^
,上上一个版本就是HEAD^^
,当然往上100个版本写100个^
比较容易数不过来,所以写成HEAD~100
。1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git reset --hard HEAD^ 3 HEAD is now at a25e8e4 wrote a readme file.
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git reset --hard 6fa7dc43a0aa553ae0a3cf9b9a6c9b2757a8e556 3 HEAD is now at 6fa7dc4 wrote a readme file.
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git reflog 3 6fa7dc4 HEAD@{0}: reset: moving to 6fa7dc43a0aa553ae0a3cf9b9a6c9b2757a8e556 4 a25e8e4 HEAD@{1}: reset: moving to HEAD^ 5 6fa7dc4 HEAD@{2}: commit: wrote a readme file. 6 a25e8e4 HEAD@{3}: commit (initial): wrote a readme file.
master
,以及指向master
的一个指针叫HEAD
。add
到暂存区,那就不会加入到commit
中。1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git checkout -- readme.md
1)是readme.md自修改后还没有被放到暂存区,现在,撤销修改就回到和版本库一模一样的状态;2)是readme.md已经添加到暂存区后,又作了修改,现在,撤销修改就回到添加到暂存区后的状态。
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ rm test.md 3 4 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 5 $ git status 6 On branch master 7 Changes not staged for commit: 8 (use "git add/rm <file>..." to update what will be committed) 9 (use "git checkout -- <file>..." to discard changes in working directory) 10 11 deleted: test.md 12 13 no changes added to commit (use "git add" and/or "git commit -a") 14 15 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 16 $ git checkout -- test.md 17 18 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 19 $ git status 20 On branch master 21 nothing to commit, working tree clean
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ rm test.md 3 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 4 $ git status 5 On branch master 6 Changes not staged for commit: 7 (use "git add/rm <file>..." to update what will be committed) 8 (use "git checkout -- <file>..." to discard changes in working directory) 9 10 deleted: test.md 11 12 no changes added to commit (use "git add" and/or "git commit -a") 13 14 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 15 $ git rm test.md 16 rm ‘test.md‘ 17 18 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 19 $ git commit -m "remove test.md" 20 [master 1f8e8c7] remove test.md 21 1 file changed,45 deletions(-) 22 delete mode 100644 test.md 23 24 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 25 $ git status 26 On branch master 27 nothing to commit, working tree clean
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ ssh-keygen -t rsa -C "zhangbocheng189@163.com" 3 Generating public/private rsa key pair. 4 Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): zhangbc 5 Enter passphrase (empty for no passphrase): 6 Enter same passphrase again: 7 Your identification has been saved in zhangbc. 8 Your public key has been saved in zhangbc.pub. 9 The key fingerprint is: 10 SHA256:ULusTjP9zWYbldd/snUjJIgG1Jwqqzu1QtT7m2I7zXQ zhangbocheng189@163.com 11 The key‘s randomart image is: 12 +---[RSA 2048]----+ 13 | .o o | 14 | . = . | 15 | . .o . | 16 | . o ..o... ..| 17 |. + oS. . .o o| 18 | . + ..E o. ..| 19 |. o * * . ....=| 20 | + = *.o . oo..++| 21 | .=.+oo .o+.. | 22 +----[SHA256]-----+
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git remote add origin git@github.com:zhangbc/learngit.git
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git push -u origin master 3 Permission denied (publickey). 4 fatal:Could not read from remote repository. 5 6 Please make sure you have the correct access rights 7 and the repository exists.
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ ssh -T -v git@github.com 3 OpenSSH_7.3p1,OpenSSL1.0.2k26Jan2017 4 debug1:Reading configuration data /etc/ssh/ssh_config 5 debug1:Connecting to github.com [192.30.253.113] port 22. 6 debug1:Connection established. 7 debug1: identity file /c/Users/Administrator/.ssh/id_rsa type 1 8 debug1: key_load_public:No such file or directory 9 debug1: identity file /c/Users/Administrator/.ssh/id_rsa-cert type -1 10 debug1: key_load_public:No such file or directory 11 debug1: identity file /c/Users/Administrator/.ssh/id_dsa type -1 12 debug1: key_load_public:No such file or directory 13 debug1: identity file /c/Users/Administrator/.ssh/id_dsa-cert type -1 14 debug1: key_load_public:No such file or directory 15 debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa type -1 16 debug1: key_load_public:No such file or directory 17 debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa-cert type -1 18 debug1: key_load_public:No such file or directory 19 debug1: identity file /c/Users/Administrator/.ssh/id_ed25519 type -1 20 debug1: key_load_public:No such file or directory 21 debug1: identity file /c/Users/Administrator/.ssh/id_ed25519-cert type -1 22 debug1:Enabling compatibility mode for protocol 2.0 23 debug1:Local version string SSH-2.0-OpenSSH_7.3 24 debug1:Remote protocol version 2.0, remote software version libssh-0.7.0 25 debug1: no match: libssh-0.7.0 26 debug1:Authenticating to github.com:22 as ‘git‘ 27 debug1: SSH2_MSG_KEXINIT sent 28 debug1: SSH2_MSG_KEXINIT received 29 debug1: kex: algorithm: curve25519-sha256@libssh.org 30 debug1: kex: host key algorithm: ssh-rsa 31 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC:<implicit> compression: none 32 debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC:<implicit> compression: none 33 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 34 debug1:Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 35 debug1:Host‘github.com‘ is known and matches the RSA host key. 36 debug1:Found key in/c/Users/Administrator/.ssh/known_hosts:1 37 debug1: rekey after 134217728 blocks 38 debug1: SSH2_MSG_NEWKEYS sent 39 debug1: expecting SSH2_MSG_NEWKEYS 40 debug1: rekey after 134217728 blocks 41 debug1: SSH2_MSG_NEWKEYS received 42 debug1: SSH2_MSG_SERVICE_ACCEPT received 43 debug1:Authentications that can continue: publickey 44 debug1:Next authentication method: publickey 45 debug1:Offering RSA public key:/c/Users/Administrator/.ssh/id_rsa 46 debug1:Authentications that can continue: publickey 47 debug1:Trying private key:/c/Users/Administrator/.ssh/id_dsa 48 debug1:Trying private key:/c/Users/Administrator/.ssh/id_ecdsa 49 debug1:Trying private key:/c/Users/Administrator/.ssh/id_ed25519 50 debug1:No more authentication methods to try. 51 Permission denied (publickey).
1 Administrator@WIN-9S4D59CISAA MINGW64 ~(master) 2 $ find -name *pub 3 ./.android/adbkey.pub 4 ./.ssh/id_rsa.pub 5 ./AppData/Roaming/VanDyke/Config/KnownHosts/160.16.205.132[160.16.205.132]22.pub
1 Administrator@WIN-9S4D59CISAA MINGW64 /f/learngit (master) 2 $ git remote -v 3 origin git@github.com:zhangbc/learngit.git (fetch) 4 origin git@github.com:zhangbc/learngit.git (push)
1 Administrator@WIN-9S4D59CISAA MINGW64 /e/DataStructure/dataStructure (master) 2 $ git rm -f gitReadme.md 3 rm ‘gitReadme.md‘ 4 5 Administrator@WIN-9S4D59CISAA MINGW64 /e/DataStructure/dataStructure (master) 6 $ git commit -m "delete file Gitreadme.md" 7 [master 20828c2] delete file Gitreadme.md 8 1 file changed,4 deletions(-) 9 delete mode 100644 gitReadme.md 10 11 Administrator@WIN-9S4D59CISAA MINGW64 /e/DataStructure/dataStructure (master) 12 $ git push origin master 13 Counting objects:2,done. 14 Delta compression using up to 4 threads. 15 Compressing objects:100%(2/2),done. 16 Writing objects:100%(2/2),236 bytes |0 bytes/s,done. 17 Total2(delta 1), reused 0(delta 0) 18 remote:Resolving deltas:100%(1/1), completed with 1local objects. 19 To github.com:zhangbc/dataStructure.git 20 c182956..20828c2 master -> master
zhangbc@working MINGW64 /d/BaiduYunDownload/dataStructure (master)
$ git remote remove origin
zhangbc@working MINGW64 /d/BaiduYunDownload $ git clone git@github.com:zhangbc/cnblogs_Scrapy.git Cloning into ‘cnblogs_Scrapy‘... remote:Counting objects:33,done. remote:Compressing objects:100%(28/28),done. remote:Total33(delta 3), reused 33(delta 3), pack-reused 0 Receiving objects:100%(33/33),34.74KiB|0 bytes/s,done. Resolving deltas:100%(3/3),done.
标签:进阶 原因 git log sans 问题 exp title out client
原文地址:http://www.cnblogs.com/zhangbc/p/6523090.html