第三次作业,github的基本操作

时间:2022-11-24 18:27:22

chengjiangtao@pc MINGW32 ~
$ git config --global user.name "chengjiangtao"

chengjiangtao@pc MINGW32 ~
$ git config --global user.email "1271419861@qq.com"

chengjiangtao@pc MINGW32 ~
$ mkdir learngit

chengjiangtao@pc MINGW32 ~
$ cd leargit
bash: cd: leargit: No such file or directory

chengjiangtao@pc MINGW32 ~
$ cd learngit

chengjiangtao@pc MINGW32 ~/learngit
$ pwd
/c/Users/chengjiangtao/learngit

chengjiangtao@pc MINGW32 ~/learngit
$ git init
Initialized empty Git repository in C:/Users/chengjiangtao/learngit/.git/

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "wrote a readme file"
[master (root-commit) e05e1cf] wrote a readme file
1 file changed, 2 insertions(+)
create mode 100644 readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: readme

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

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git diff readme
diff --git a/readme b/readme
index d8036c1..013b5bc 100644
--- a/readme
+++ b/readme
@@ -1,2 +1,2 @@
-Git is a version control system.
+Git is a distributed version control system.
Git is free software.
\ No newline at end of file

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "add distributed"
[master b4c23b1] add distributed
1 file changed, 1 insertion(+), 1 deletion(-)

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
nothing to commit, working directory clean

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "append GPL"
[master e68c5cd] append GPL
1 file changed, 1 insertion(+), 1 deletion(-)

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git log
commit e68c5cd240ef48e1fa4a391f647b87e2cb1bdd1e
Author: chengjiangtao <1271419861@qq.com>
Date: Thu Jan 7 15:19:02 2016 +0800

append GPL

commit b4c23b13acdb4239f6c9915bc9297d1b0c685412
Author: chengjiangtao <1271419861@qq.com>
Date: Thu Jan 7 15:17:07 2016 +0800

add distributed

commit e05e1cf5433d70ce2ceaeb3db0dd6faebe17e385
Author: chengjiangtao <1271419861@qq.com>
Date: Thu Jan 7 15:12:52 2016 +0800

wrote a readme file

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git log --pretty=oneline
e68c5cd240ef48e1fa4a391f647b87e2cb1bdd1e append GPL
b4c23b13acdb4239f6c9915bc9297d1b0c685412 add distributed
e05e1cf5433d70ce2ceaeb3db0dd6faebe17e385 wrote a readme file

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git reset --hard HEAD^
HEAD is now at b4c23b1 add distributed

chengjiangtao@pc MINGW32 ~/learngit (master)
$ cat readme
Git is a distributed version control system.
Git is free software.
chengjiangtao@pc MINGW32 ~/learngit (master)
$ git log
commit b4c23b13acdb4239f6c9915bc9297d1b0c685412
Author: chengjiangtao <1271419861@qq.com>
Date: Thu Jan 7 15:17:07 2016 +0800

add distributed

commit e05e1cf5433d70ce2ceaeb3db0dd6faebe17e385
Author: chengjiangtao <1271419861@qq.com>
Date: Thu Jan 7 15:12:52 2016 +0800

wrote a readme file

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git reset --hard e68c5cd
HEAD is now at e68c5cd append GPL

chengjiangtao@pc MINGW32 ~/learngit (master)
$ cat readme
Git is a distributed version control system.
Git is free software distributed under the GPL.
chengjiangtao@pc MINGW32 ~/learngit (master)
$ git reflog
e68c5cd HEAD@{0}: reset: moving to e68c5cd
b4c23b1 HEAD@{1}: reset: moving to HEAD^
e68c5cd HEAD@{2}: commit: append GPL
b4c23b1 HEAD@{3}: commit: add distributed
e05e1cf HEAD@{4}: commit (initial): wrote a readme file

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: readme

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

license

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

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add license

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

new file: license
modified: readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "understand how stage works"
[master d9bb205] understand how stage works
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 license

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
nothing to commit, working directory clean

chengjiangtao@pc MINGW32 ~/learngit (master)
$ cat readme
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

modified: readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ cat readme
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes of files.
chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "git tracks changes"
[master ab46c84] git tracks changes
1 file changed, 2 insertions(+), 1 deletion(-)

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: readme

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

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git diff HEAD -- readme
diff --git a/readme b/readme
index db28b2c..9a8b341 100644
--- a/readme
+++ b/readme
@@ -1,4 +1,4 @@
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
-Git tracks changes.
\ No newline at end of file
+Git tracks changes of files.
\ No newline at end of file

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: readme

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

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git checkout --readme
error: unknown option `readme'
usage: git checkout [<options>] <branch>
or: git checkout [<options>] [<branch>] -- <file>...

-q, --quiet suppress progress reporting
-b <branch> create and checkout a new branch
-B <branch> create/reset and checkout a branch
-l create reflog for new branch
--detach detach the HEAD at named commit
-t, --track set upstream info for new branch
--orphan <new-branch>
new unparented branch
-2, --ours checkout our version for unmerged files
-3, --theirs checkout their version for unmerged files
-f, --force force checkout (throw away local modifications)
-m, --merge perform a 3-way merge with the new branch
--overwrite-ignore update ignored files (default)
--conflict <style> conflict style (merge or diff3)
-p, --patch select hunks interactively
--ignore-skip-worktree-bits
do not limit pathspecs to sparse entries only
--ignore-other-worktrees
do not check if another worktree is holding the given ref
--progress force progress reporting

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git checkout -- readme

chengjiangtao@pc MINGW32 ~/learngit (master)
$ cat readme
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes.
chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add test.txt

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "add test.txt"
On branch master
Untracked files:
TEST.txt

nothing added to commit but untracked files present

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git add TEST.txt

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "add test,txt"
[master bb52781] add test,txt
1 file changed, 1 insertion(+)
create mode 100644 TEST.txt

chengjiangtao@pc MINGW32 ~/learngit (master)
$ rm TEST.txt

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

deleted: TEST.txt

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

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git rm TEST.txt
rm 'TEST.txt'

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git commit -m "remove test.txt"
[master 2758aa6] remove test.txt
1 file changed, 1 deletion(-)
delete mode 100644 TEST.txt

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git status
On branch master
nothing to commit, working directory clean

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git checkout -- TEST.txt
error: pathspec 'TEST.txt' did not match any file(s) known to git.

chengjiangtao@pc MINGW32 ~/learngit (master)
$ ssh-keygen -t rsa -C "1271419861@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/chengjiangtao/.ssh/id_rsa):
Created directory '/c/Users/chengjiangtao/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/chengjiangtao/.ssh/id_rsa.
Your public key has been saved in /c/Users/chengjiangtao/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:mK6jZ9wuVi+fdsIDegb2GkXJewaYwDWHeqrqUvm3wnI 1271419861@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| ...o.. |
| ...* . |
| .o = |
| . .. = |
| + = S |
| + oooo |
| o =.*.+ |
|o . EoB *.. |
|=..BoXo=o+ |
+----[SHA256]-----+

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git remote add origin git@github.com:chengjiangtao/learngit.git

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git push -u origin master
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git push -u origin master
The authenticity of host 'github.com (192.30.252.128)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git remote add origin git@github.com:chengjiangtao/learngit.git
fatal: remote origin already exists.

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git push -u origin master
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
Counting objects: 20, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (20/20), 1.65 KiB | 0 bytes/s, done.
Total 20 (delta 4), reused 0 (delta 0)
To git@github.com:chengjiangtao/learngit.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git clone git@github.com/chengjiangtao/CoffeeMachine
fatal: repository 'git@github.com/chengjiangtao/CoffeeMachine' does not exist

chengjiangtao@pc MINGW32 ~/learngit (master)
$ git clone git@github.com:chengjiangtao/CoffeeMachine
Cloning into 'CoffeeMachine'...
remote: Counting objects: 1943, done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 1943 (delta 5), reused 0 (delta 0), pack-reused 1924
Receiving objects: 100% (1943/1943), 7.81 MiB | 174.00 KiB/s, done.
Resolving deltas: 100% (417/417), done.
Checking connectivity... done.
Checking out files: 100% (1618/1618), done.

chengjiangtao@pc MINGW32 ~/learngit (master

第三次作业,github的基本操作