Git入门初探三

Git入门初探三[待完善]

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ gti statud
bash: gti: command not found

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ gti status
bash: gti: command not found

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   readme.txt


Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ cat readme.txt
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.
Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git commit -m "git tracks change"
[master 332319e] git tracks change
 1 file changed, 2 insertions(+), 1 deletion(-)

Administrator@ICOS-20180710CX MINGW64 /g/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.txt

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

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git diff HEAD -- readme.txt
diff --git a/readme.txt b/readme.txt
index cbfb4b1..636cfcc 100644
--- a/readme.txt
+++ b/readme.txt
@@ -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.

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ cat readme.txt
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.

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git commit -m "second commit"
[master 623338c] second commit
 1 file changed, 1 insertion(+), 1 deletion(-)

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git diff HEAD -- readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git diff HEAD -- readme.txt
diff --git a/readme.txt b/readme.txt
index 636cfcc..4019639 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,3 +2,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 of files.
+My stupid  boss still prefers SVN.

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git checkout -- readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git diff HEAD -- readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git diff HEAD -- readme.txt
diff --git a/readme.txt b/readme.txt
index 636cfcc..830f4a4 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,3 +2,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 of files.
+My stupid boss still prefers SVN.
\ No newline at end of file

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   readme.txt


Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git reset HEAD readme.txt
Unstaged changes after reset:
M       readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/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.txt

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

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git diff HEAD -- readme.txt
diff --git a/readme.txt b/readme.txt
index 636cfcc..830f4a4 100644
--- a/readme.txt
+++ b/readme.txt
@@ -2,3 +2,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 of files.
+My stupid boss still prefers SVN.
\ No newline at end of file

Administrator@ICOS-20180710CX MINGW64 /g/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.txt

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

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git reset head readme.txt
Unstaged changes after reset:
M       readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git stuts
git: 'stuts' is not a git command. See 'git --help'.

The most similar command is
        status

Administrator@ICOS-20180710CX MINGW64 /g/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.txt

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

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ cat readme.txt
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.
My stupid boss still prefers SVN.
Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git checkout -- readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ cat readme.txt
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.

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git status
On branch master
nothing to commit, working tree clean

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add test.txt
fatal: pathspec 'test.txt' did not match any files

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ^C

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add test.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ll
total 2
-rw-r--r-- 1 Administrator 197121  29 8月  24 14:10 LICENSE.txt
-rw-r--r-- 1 Administrator 197121 164 8月  25 13:40 readme.txt
-rw-r--r-- 1 Administrator 197121   0 8月  25 13:43 test.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   test.txt


Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ commit -m test.txt
bash: commit: command not found

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git commit -m test.txt
[master be55322] test.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 test.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git status
On branch master
nothing to commit, working tree clean

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ rm test.txt

Administrator@ICOS-20180710CX MINGW64 /g/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")

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git  commit
On branch master
Changes not staged for commit:
        deleted:    test.txt

no changes added to commit

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git rm test.txt
LICENSE.txt  readme.txt   test.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git rm test.txt
rm 'test.txt'

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git commit -m 'remove test.txt'
[master a61db02] remove test.txt
 1 file changed, 0 insertions(+), 0 deletions(-)
 delete mode 100644 test.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git status
On branch master
nothing to commit, working tree clean

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Created directory '/c/Users/Administrator/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:oiPFHw1DJbAXz8s4rlp1YYZ16sJliqUBjSKKOYoMKAo Administrator@ICOS-20180710CX
The key's randomart image is:
+---[RSA 2048]----+
|  .o..+.o .      |
|o ...o B o       |
|=o  o * X        |
|E  . B & o       |
|O.  = X S        |
|+. . = *         |
|  . + o          |
|   o o           |
|  ...            |
+----[SHA256]-----+

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ll
total 2
-rw-r--r-- 1 Administrator 197121  29 8月  24 14:10 LICENSE.txt
-rw-r--r-- 1 Administrator 197121 164 8月  25 13:40 readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ls -s
total 2
1 LICENSE.txt  1 readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ls -a
./  ../  .git/  LICENSE.txt  readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ll -ah
total 10K
drwxr-xr-x 1 Administrator 197121   0 825 13:47 ./
drwxr-xr-x 1 Administrator 197121   0 825 12:00 ../
drwxr-xr-x 1 Administrator 197121   0 825 13:48 .git/
-rw-r--r-- 1 Administrator 197121  29 8月  24 14:10 LICENSE.txt
-rw-r--r-- 1 Administrator 197121 164 8月  25 13:40 readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ cd /c/Users/Administrator/.ssh

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$ ll
total 5
-rw-r--r-- 1 Administrator 197121 1679 8月  25 13:56 id_rsa
-rw-r--r-- 1 Administrator 197121  411 8月  25 13:56 id_rsa.pub

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDzbOSq8+LWWMML6xtlr7LQORZVba++gpRpdlnDy5D/dRWhLEbKcM0xwHppdzJOishJ5sDkpQbrRo/tx6KspK3uinI97HS9YgNBsydHxVzCOqHOPthfUNlaepKjv0seWOdzdfszws/sm22xOp2H1vRq/O6xnYh5fjpVHyYQk29ThwYh49OSb3ZJQiPvxUO2pZkVMBOy5l7p89PwbTlsg95iEHuctug0NzZ3z7hMBRFGnHhoUABGVpwPOSwalws0guAAgtWE0S5u7QC1MBnlh1dhpIikOtlxqeCxL1d5Tlm9+Wlqy5FiB2H5MB9bCpVcSr8+Ndj1PfSiGud6u6GhEvZ7 Administrator@ICOS-20180710CX

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$ git remote add origin https://github.com/LittleLawson/learnGit.git
fatal: Not a git repository (or any of the parent directories): .git

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$ git push -u origin master^C

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$

Administrator@ICOS-20180710CX MINGW64 ~/.ssh
$ cd /g/learnGit/

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ ll
total 2
-rw-r--r-- 1 Administrator 197121  29 8月  24 14:10 LICENSE.txt
-rw-r--r-- 1 Administrator 197121 164 8月  25 13:40 readme.txt

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git remote add origin https://github.com/LittleLawson/learnGit.git

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
   ▒▒▒▒▒▒▒▒ʱ▒▒▒▒
Username for 'https://github.com': 1471831539@qq.com
9297remote: Permission to LittleLawson/learnGit.git denied to liu16659.
fatal: unable to access 'https://github.com/LittleLawson/learnGit.git/': The requested URL returned error: 403

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git remote add origin https://github.com/LittleLawson/learnGit.git
fatal: remote origin already exists.

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git push -u origin master


Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git remote rm orgin
fatal: No such remote: orgin

Administrator@ICOS-20180710CX MINGW64 /g/learnGit (master)
$ git remote -v
origin  https://github.com/LittleLawson/learnGit.git (fetch)
origin  https://github.com/LittleLawson/learnGit.git (push)



要关联一个远程库,使用命令git remote add origin git@server-name:path/repo-name.git;
关联后,使用命令git push -u origin master第一次推送master分支的所有内容;
此后,每次本地提交后,只要有必要,就可以使用命令git push origin master推送最新修改;


如果使用git push -u origin master之后,会弹出GitHub登录框的话,说明你没有使用ssh 功能。使用以下方式即可解决【前提是需要有一个事先生成ssh秘钥】:
git remote rm origin
git remote add origin git@github.com:username/repository.git
git push -u origin master
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

说文科技

看书人不妨赏个酒钱?

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值