一、安装git

$ sudo apt-get install git
如果无效。则用 yum install git

安装完成后,sudo adduser git

收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
window公钥放在C/用户目录下,如果没有,则用在window下git 客户端用 ssh-keygen 生成

进入需要生成git的目录中,git init,生成一个git初始化(注意,生成目录等都需要用git用户操作,不可用root用户操作, su git)

二、客户端
使用下面命令clone,其中server为服务器ip或服务器名
$ git clone git@server:/home/wwwroot/mygit/

git add *

git commit -m '注释'

git push

git pull 更新到本地


注意:如果push出错,则在服务器端执行下面
git config receive.denyCurrentBranch ignore

如果pull出错,则使用
git config branch.master.remote origin
git config branch.master.merge refs/heads/master

三、服务器更新代码
git push后服务器是不会显示修改的,需要如下命令

git update-server-info
git checkout -f


 

相关文章:

  • 2021-11-21
  • 2021-08-11
  • 2022-12-23
  • 2022-01-27
猜你喜欢
  • 2021-08-30
  • 2021-11-19
  • 2021-10-28
  • 2021-07-10
  • 2021-04-25
相关资源
相似解决方案