git使用

一,首次登陆
1,首先在码云上创建项目,并设置文件共享性,什么语言的,服从GPL协议
      如果删除项目就找到“管理”,然后管理设置下面有“删除项目”选项
2,码云公钥管理
注:第一次做的化就需配置且对主机上所有git管理项目生效
[ligang@centos6 ~]$ git config --global user.name "ligang"
[ligang@centos6 ~]$ git config --global user.email "2820724771@qq.com"
[ligang@centos6 ~]$ ssh-keygen -t rsa -C "2820724771@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ligang/.ssh/id_rsa):
Created directory '/home/ligang/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ligang/.ssh/id_rsa.
Your public key has been saved in /home/ligang/.ssh/id_rsa.pub.
The key fingerprint is:
1c:a7:08:30:bd:b8:a4:4b:a3:fe:d8:2e:51:f0:61:fe 2820724771@qq.com
The key's randomart image is:
+--[ RSA 2048]----+
|  o.             |
| . =.            |
|  =.o.  . .      |
|  o+.. o +       |
| o... . S        |
|.+.  E           |
|o.o              |
|o.o              |
|.o++             |
+-----------------+
+-----------------+
[ligang@centos6 ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxTd+lulhMfTNez/CjqFi5xbFDvOngvzqvubi6laOjOa3fEWQCWq4tpjO8uRBh74K73ripisI8zIWtR+4yu3Z8CqjBWiZ5iWF/TG7jgVFlGLoTYLVWxGJnvUumsd2iKQ/hS7nZLezLH9LbYnu2qmeTJ/Lvats+PqgOHBnyjC+qNubirDdqBTT9UC7FK9977o4ABoloyXiAijoJD3O8A0n0EUJtC/PGVfw96lONUxAMhI/+thMBEtIB/y28s0dKc5ghWyCgES+H4rkPAhdchci7MK8mfDNrnvpuwJ34fOC8UFWt5F/IUOX/e7GqNPt7XeQ8Fk7iwXAnrDa37ZFHhaLHw== 2820724771@qq.com
[ligang@centos6 ~]$ ^C
[ligang@centos6 ~]$ ssh -T git@git.oschina.net
The authenticity of host 'git.oschina.net (116.211.167.14)' can't be established.
RSA key fingerprint is e3:ee:82:78:fb:c0:ca:24:65:69:ba:bc:47:24:6f:d4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.oschina.net,116.211.167.14' (RSA) to the list of known hosts.
Connection closed by 116.211.167.14
[ligang@centos6 ~]$ git clone git@gitee.com/ZuoKanYunQi/socket.git
fatal: Could not switch to 'git@gitee.com/ZuoKanYunQi': No such file or directory
[ligang@centos6 ~]$ ssh -T git@git.oschina.net
Welcome to Gitee.com, ????!
[ligang@centos6 ~]$ git clone git@gitee.com/ZuoKanYunQi/socket.git
fatal: Could not switch to 'git@gitee.com/ZuoKanYunQi': No such file or directory
[ligang@centos6 ~]$ git clone git@gitee.com/ZuoKanYunQi/socket
fatal: Could not switch to 'git@gitee.com/ZuoKanYunQi': No such file or directory
 
[ligang@centos6 ~]$ git config --global user.name "ZuoKanYunQi"
[ligang@centos6 ~]$ git config --global user.email "2820724771@qq.com"
[ligang@centos6 ~]$ ssh-keygen -t rsa -C "2820724771@qq.com" //一定要与码云账号上的一致,否则会出问题。
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ligang/.ssh/id_rsa):
/home/ligang/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ligang/.ssh/id_rsa.//私钥
Your public key has been saved in /home/ligang/.ssh/id_rsa.pub.//私钥
The key fingerprint is:
d7:d5:78:0f:78:12:37:47:e3:c8:83:c7:49:b9:e1:a2 2820724771@qq.com
The key's randomart image is:
+--[ RSA 2048]----+
|            ..+oo|
|            =*+=.|
|           .+BB.o|
|           o.*.o.|
|        S o o   .|
|         E       |
|                 |
|                 |
|                 |
+-----------------+
[ligang@centos6 ~]$ ssh -T git@git.oschina.net
Permission denied (publickey).
3,复制公钥到码云上,ssh公钥
[ligang@centos6 ~]$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAxnErFquA3Frr4k6EqCUi28CEhjLaI/TNcMhGJbYJ07+ZqUl76kKPbpKiekvcLvUNjWU/tLkMmINsTvS/e0AhOFqjrPTIFq74w7TcAYC+3kNoW+tRzFWVLCE/XRMB5yM62CSozYWMd6ysDPnxbANnMIRmJum3jgwKmocgcZN7w68kGBGFUJxsN+PqMuB+USEe2aaN/whpvZjQZO4yaS3ggiVaR91geDM7Gs94fjk6VnaDSNLKAtkxRDysLTjQE3cQDZ67PG6apqIf/BFg1FvqAQNWQ6N0pZKA+q6QSzEUUkdqWQvpZpBfmV67uEP4jhZhsqKIrA0uAx+SzxTWia4vtQ== 2820724771@qq.com
4,公钥添加测试
[ligang@centos6 socket]$ ssh -T git@git.oschina.net
Welcome to Gitee.com, ????!
5,git下载文件测试
[ligang@centos6 ~]$ cd gitee
[ligang@centos6 gitee]$ git clone git@gitee.com:ZuoKanYunQi/socket.git
Initialized empty Git repository in /home/ligang/gitee/socket/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[ligang@centos6 gitee]$ ls
socket
6,git提交创建的文件
[ligang@centos6 socket]$ git add ./my_socket_server.c
[ligang@centos6 socket]$ git commit -m"Add file my_socket_server.c"
[master 6788f29] Add file my_socket_server.c
1 files changed, 82 insertions(+), 0 deletions(-)
create mode 100644 my_socket_server.c
[ligang@centos6 socket]$  git push
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.08 KiB, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@gitee.com:ZuoKanYunQi/socket.git
   b98196d..6788f29  master -> master
7,修改后的文件再次提交
[ligang@centos6 socket]$ git diff
diff --git a/my_socket_server.c b/my_socket_server.c
index bba64a8..0de3e29 100644
--- a/my_socket_server.c
+++ b/my_socket_server.c
@@ -68,6 +68,7 @@ int main(int argc,char **argv)
             return -2;
         }
         memset(buf,0,sizeof(buf));
+        printf("begin to read\n");
         read(new_fd,buf,sizeof(buf));
         printf("%s\n",buf);
@@ -78,5 +79,5 @@ int main(int argc,char **argv)
     }
     close(sock_fd);
-    //return 0;
+    return 0;
}
[ligang@centos6 socket]$ git add ./my_socket_server.c
[ligang@centos6 socket]$ git commit -m"polish file my_socket_server.c"
[master 8ef32a4] polish file my_socket_server.c
1 files changed, 2 insertions(+), 1 deletions(-)
[ligang@centos6 socket]$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 375 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To git@gitee.com:ZuoKanYunQi/socket.git
   6788f29..8ef32a4  master -> master
8,删除后的文件再次同步
[ligang@centos6 socket]$ ls
my_socket_server.c  README.md
[ligang@centos6 socket]$ rm -rf my_socket_server.c
[ligang@centos6 socket]$ ls
README.md
[ligang@centos6 socket]$ checkout .
-bash: checkout: command not found
[ligang@centos6 socket]$ git checkout .
[ligang@centos6 socket]$ ls
my_socket_server.c  README.md
[ligang@centos6 socket]$
 
二,第二次登陆,共享
[ligang@centos6 gitee]$ git clone git@gitee.com:ZuoKanYunQi/socket.git
Initialized empty Git repository in /home/ligang/gitee/socket/.git/
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (10/10), done.
remote: Total 12 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (12/12), done.
Resolving deltas: 100% (2/2), done.
[ligang@centos6 gitee]$ ls
socket
posted @ 2018-03-22 14:09  李刚blog  阅读(718)  评论(0编辑  收藏  举报