#免密码提交
# 找个合适的位置 创建仓库
git init --bare sample.git
# 生成密串
ssh-keygen -t rsa -C "alw88976@live.com"
# 进入.ssh,新建一个authorized_keys文件
# 给600权限
chmod 600 authorized_keys
将 id_rsa.pub 将加密串 复制到 authorized_keys文件
# 测试
ssh zwp@192.168.1.xxx
检出脚本
# 复制 /sample.git/hooks/post-update.sample 为 post-update
13.打开post-update,先清空内容,然后进行编辑如下
#!/bin/bash
#var=`git show`
#PHP /var/www/html/mail.php "$var" //邮件内容
# sample 先把项目克隆下来
cd /var/www/html/sample
unset GIT_DIR
git checkout master
git pull
如果没有成功执行,可在目录下 直接运行该文件并进行 debug
14.出于安全考虑,只让克隆提交版本库,不让登陆终端
$ which git-shell
/usr/bin/git-shell vi /etc/passwd
ph:x:1000:1000:zw:/home/zph:/usr/bin/git-shell
// 上传至 github
git init
# 收纳命令
git add -A
git commit -m "first commit"
git remote add origin https://github.com/aaa/sample.git
git push -u origin master
遇到的错误
On branch master
Your branch is up-to-date with ‘origin/master’.
git add xxx
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as ‘master’.
fatal: The remote end hung up unexpectedly
git push origin master
git push 以下错误时
[外链图片转存中…(img-OXmu7Ydw-1649345994133)]
#可以通过如下命令进行代码合并【注:pull=fetch+merge]
git pull --rebase origin master