合併多個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 '非法訪問';
}
複製代碼