写点什么

使用 Git 分布式控制系统,java 岗位面试题总结

用户头像
极客good
关注
发布于: 刚刚

4.初始化 Git 版本仓库:


[root@caq ~]# cd caq.git/


[root@caq caq.git]# git --bare init Initialized empty Git repository in /root/caq.git/


5.服务器上的 Git 仓库此时已经部署好了,但是还不能分享给其他人。需要有个协议来限制。猜到了吧,是 ssh 协议!


在客户端生成 ssh 密钥


[root@caq ~]# ssh-keygen


Generating public/private rsa key pair.


Enter file in which to save the key (/root/.ssh/id_rsa):


Created directory ‘/root/.ssh’.


Enter passphrase (empty for no passphrase):


Enter same passphrase again:


Your identification has been saved in /root/.ssh/id_rsa.


Your public key has been saved in /root/.ssh/id_rsa.pub.


The key fingerprint is:


65:4a:53:0d:4f:ee:49:4f:94:24:82:16:7a:dd:1f:28 root@caq.com


The key’s randomart image is:


±-[ RSA 2048]----+


| .o+oo.o. |


| .oo *.+. |


| …+ E * o |


| o = + = . |


| S o o |


| |


| |


| |


| |


±----------------+


将客户机的公钥传递给 Git 服务器:


[root@caq ~]# ssh-copy-id 192.168.10.10 root@192.168.10.10’s password: Number of key(s) added: 1 Now try logging into the machine, with: “ssh ‘192.168.10.10’” and check to make sure that only the key(s) you wanted were added.


6.现在客户端就可以克隆服务端的版本仓库了。


[root@caq ~]# git clone root@192.168.10.10:/root/caq.git Cloning into ‘caq’… warning: You appear to have cloned an empty repository.


7.初始化下 Git 工作环境:


[root@caq ~]# git config --global user.name “Liu Chuan” [root@caq ~]# git config --global user.email “root@caq.com” [root@caq ~]# git config --global core.editor vim


8.向 Git 版本仓库中提交一个新文件:


[root@caq caq]# echo “I am fine” > readme.txt


[root@caq caq]# git add readme.txt


[root@caq caq]# git status


# On branch master


# Initial commit


# Changes to be committed:


# (use “git rm --cached …” to unstage)


# new file: readme.txt


[root@caq caq ]# git commit -m “Clone the Git repository”


[master (root-commit) c3961c9] Clone the Git repository


Committer: root


1 file changed, 1 insertion(+)


create mode 100644 readme.txt


[root@linuxprobe caq]# git status


# On branch master


nothing to commit, working directory cle


【一线大厂Java面试题解析+核心总结学习笔记+最新架构讲解视频+实战项目源码讲义】
浏览器打开:qq.cn.hn/FTf 免费领取
复制代码


an


9.向服务器发送文件


[root@caq caq]# git remote add server root@192.168.10.10:/root/caq.git


[root@caq caq]# git push -u server master


Counting objects: 3, done.


Writing objects: 100% (3/3), 261 bytes | 0 bytes/s, done.


Total 3 (delta 0), reused 0 (delta 0)


To root@192.168.10.10:/root/caq.git


[new branch] master -> master


Branch master set up to track remote branch master from server.

用户头像

极客good

关注

还未添加个人签名 2021.03.18 加入

还未添加个人简介

评论

发布
暂无评论
使用Git分布式控制系统,java岗位面试题总结