顯示具有 github 標籤的文章。 顯示所有文章
顯示具有 github 標籤的文章。 顯示所有文章

2020年9月11日 星期五

不同git庫不同目錄同一個PHPStorm專案使用XDebug

開一個新空白專案

 File => New Project => PHP Empty Project

用ConEmu64 + Git Bash 到剛剛開的PHP專案下拉取不同專案
$ git clone git@github.com:kalecgos0616/project_index.git
$ git clone git@github.com:kalecgos0616/project_codes.git

配置SFTP

不同git不同目錄的code更新到伺服器不同路徑
C:\Users\PhpstormProjects\project_workspace\project_index => /var/www/html/project_index
C:\Users\PhpstormProjects\project_workspace\project_codes => /var/www/html/project_codes




配置XDebug

Open edit Run/Debug configurations dialog => Add New Configuration => PHP Remote Debug => 配置Server

Host 必須設 開發機上的vhost域名:example.com
配置本地和遠程對應的路徑
如果還是不能斷點,在開發機上對本機測試XDebug 端口有沒有通
# telnet 192.168.1.7 9000
Trying 192.168.1.7...
telnet: connect to address 192.168.1.7: Connection timed out
沒有通要用 Windows - CentOS 遠端XDebug調試PHP 的 2. 打開Windows的port 

結果

成功斷點


2020年4月25日 星期六

在github issues留言時插入code

如果要插入css,使用三個 ` 包起來,前面聲明css


```css
@font-face {  
  ...  
  src: url("assets/vant-icon-db1de1.woff2") format('woff2')  
}
```
s
結果是:



2014年11月23日 星期日

git同時push到兩個repo

情境:
以github和gitlab為例,假設他們各自有不同的內容要整合在一起

模擬環境
分別在github和gitlab建立新專案(ex 專案名稱mp),gitlab為master的pull
master 更新檔案 pull從gitlab
master 上傳檔案push到 gitlab和github(github純備份用,因為gitlab上是和其他人共同開發)

(分別在github和gitlab的mp.git新增不同的內容,我們之後要整合在一起)

拉下gitlab檔案
$ git clone git@xxx.tw:bear/mp.git gitlab_mp #用ssh要在gitlab設定keys,用https不用,但要輸入gitlab的帳號密碼
新增remote
$ git remote add github git@github.com:bear/mp.git
更新remote(remote branch會多remotes/github/master,用git branch -a 查詢)
$ git remote update

更新特定的remote

$ git remote update github

(這邊假設github和gitlab裡面各自有不同內容要整合,如果備份的repo為新開的repo可以略過a.b.c這三步)
a. 開github的branch
$ git checkout -b github remotes/github/master
b. 切回master
$ git checkout master
c. 將github整合進gitlab
$ git rebase github


git pull(做這步之後才能push,中間有conflict就手動改)
$ git pull #這步會多一個git merge的 commit
設定origin remote的url
$ git remote set-url origin --push --add git@xxx.tw:bear/mp2.git
$ git remote set-url origin --push --add git@github.com:bear/mp.git
檢查remote 會push到哪裡
$ git remote -v
github  git@github.com:bear/mp.git (fetch)
github  git@github.com:bear/mp.git (push)
origin  git@xxx.tw:bear/mp2.git (fetch)  # 因為git push預設是git push origin master,所以master會抓自架gitlab的repo
origin  git@xxx.tw:bear/mp2.git (push) # master會push到 gitlab
origin  git@github.com:bear/mp.git (push) # master也會push到 github
最後git push就能同時推到兩個不同的repo去了
$ git push

刷新gitlab和github頁面檢查

要更改預設master pull的repo
修改 .git/config 的
[remote "origin"]
    url = git@xxx.tw:bear/mp2.git #改成你要pull的repo

參考資料:
http://stackoverflow.com/questions/849308/pull-push-from-multiple-remote-locations 採用Malvineous的答案

關於刪除branch
移除gitlab上多餘的branch
$ git push origin --delete alt(多餘的branch名字)
本地的branch要分開刪,沒辦法一起刪
$ git branch -D alt
把本地remote的branch( git branch -a )也刪
# git branch --delete --remotes origin/alt

push新的branch到remote repository
$ git push origin exhibition:exhibition3
這樣遠端倉庫就會新建exhibition3分支,內容是本地端exhibition的內容,另外origin是你remote的名字

將遠端master branch拉到本地端exhibition branch
$ git pull origin master:exhibition
語法:
git pull <remote_name> <remote_branch>:<local_branch>

將本地端exhibition branch推到遠端master branch
$ git push origin exhibition:master
語法:
git push <remote_name> <local_branch>:<remote_branch>