🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
宝塔用git部署php项目代码流程: 1. 码云(https://gitee.com/)申请账号,建立测试仓库(私有仓库) ![](https://img.kancloud.cn/42/94/42945af5fb1051dfbb60f38ac03eccf7_1364x974.png) 2. 服务器安装宝塔,命令:```yum install -y wget && wget -O install.sh https://download.bt.cn/install/install_6.0.sh && sh install.sh ed8484bec``` 3. 服务器安装git 3.1:服务器安装git,命令:yum -y install git,查看是否安装成功命令:git version,如图所示: ![](https://img.kancloud.cn/6b/bd/6bbd5e7f57acb894bb1ef1cfc0382538_377x40.png) 3.2:在宝塔中找到映射的git项目根目录,克隆git代码库命令:git clone -b master(分支)url(仓库地址) ![](https://img.kancloud.cn/4e/f8/4ef80ad946c6803c811483536f0ccad5_808x142.png) 3.3:在宝塔中找到映射的git项目根目录,查看是否拉取成功,出现该下图,代表成功 ![](https://img.kancloud.cn/5f/db/5fdb16c4ae5a54b0745d8af10925698f_1087x625.png) 3.4:首次拉取后,测试拉取和上传,拉取命令:``` git pull ```,如图所示: ![](https://img.kancloud.cn/43/0f/430f25439407febd1d907d101a9dda08_454x69.png) 3.5:上传分为三个步骤【1:添加文件 2:提交本地 3:检查本地提交文件 4:推送远程】 &nbsp; &nbsp; &nbsp;3.5.1:添加文件,命令:```git add .``` &nbsp; &nbsp; &nbsp;3.5.2:提交本地,命令:```git commit -m 描述``` &nbsp; &nbsp; &nbsp;3.5.3:检查本地提交文件,命令:```git status ``` &nbsp; &nbsp; &nbsp;3.5.4:推送远,命令:```git push ``` <span style="color:red">注意1:推送远程时,需要输入账号密码[推送平台的账号密码],如果二次推送以后,不需要每次都输入账号密码信息,可以使用命令:``` git config --global credential.helper store ```,二次推送及以后,则不需要再输入账号密码信息了,直接就可以推送了 注意2:如果gitee(码云上的是私有仓库,则需要配置服务器生成公钥,gitee配置公钥,匹配后才可以进行git的克隆、拉取、推送等操作)</span> 3.6:服务器和gitee公钥配对 &nbsp; &nbsp; &nbsp;3.6.1:进入服务器,输入命令,生成公钥命令:```ssh-keygen -t rsa -C "1013762171@qq.com``` &nbsp; &nbsp; &nbsp;3.6.2:复制公钥命令:` cat ~/.ssh/id_rsa.pub `,如图所示: ![](https://img.kancloud.cn/82/20/8220c0c9f1f22f337507301cb358525d_1246x85.png) &nbsp; &nbsp; &nbsp;3.6.3:到码云gitee,找到仓库->管理->部署公钥管理,添加公钥:` cat ~/.ssh/id_rsa.pub `,如图所示: ![](https://img.kancloud.cn/ec/be/ecbe16d9aace98cd10ca12e7ac320e1a_1338x648.png) &nbsp; &nbsp; &nbsp;3.6.4:添加完成的公钥,即可进行git的任何操作如图所示: ![](https://img.kancloud.cn/b5/72/b5728d3c10b8f293e9b0b718c6181770_1341x667.png)