合并多个commitphp
git rebase -i HEAD~{NUM} git rebase -i start end 会进入一个指定区间的commit列表 根据提示进行文本编辑 选择是否合并 或者放弃某个提交 ## 选项说明 pick:保留该commit(缩写:p) reword:保留该commit,但我须要修改该commit的注释(缩写:r) edit:保留该commit, 但我要停下来修改该提交(不单单修改注释)(缩写:e) squash:将该commit和前一个commit合并(缩写:s) fixup:将该commit和前一个commit合并,但我不要保留该提交的注释信息(缩写:f) exec:执行shell命令(缩写:x) drop:我要丢弃该commit(缩写:d) 复制代码
编辑完成 :wq后 会自动执行rebase过程
期间可能会出现代码冲突
-- 动解决而后 执行git rebase --continue
-- 或者执行 git rebase --abort 放弃rebase 过程
复制代码
版本控制中移除文件或文件夹git
git rm --cache [file_path|dir_path]
复制代码
每当本地push代码,还得在服务器上git pull。这样太麻烦了。git支持hook机制,相似事件通知,好比git服务器收到push请 求,而且接受完代码提交时触发。须要在hooks目录下建立post-receive文件 服务器操做web
Git - 生成 SSH公钥 , Linux 下多密钥管理shell
博主这里用的是php 用其余语言也是同样的 只要能调用到git pull 就OKjson
<?php $pwd = '密码xxx'; error_reporting(E_ALL); $gitPost = json_decode(file_get_contents("php://input"), true); // file_put_contents('log', $gitPost); if(isset($gitPost['password']) && $gitPost['password'] == $pwd){ // 这里只是最简单的拉取代码,若是要作更加多的操做,如验证、日志,请本身解析push内容并操做 // 获取push数据内容的方法 $requestBody = file_get_contents("php://input"); // 只需这一行代码即可拉取 // 目录换成项目的目录 $command = "cd /data/wwwroot/wx-luckyShop " . "&& git checkout master" . "&& git branch -D master-clone && git branch master-clone " . "&& git fetch " . "&& git reset --hard origin/master > GitPull.log " . "&& echo `cat GitPull.log`"; $result = shell_exec($command); echo($result . "<br/>\n"); echo date("Y-m-d H:i:s",time()); // 查看是哪一个用户执行该命令 // echo system("whoami"); }else{ echo '非法访问'; } 复制代码