在這邊把過程記錄起來,順便列出好用的工具。
列出目前所有插件的位置
基礎指令
1.
.htaccess
要啟用這個功能,必須要先修改伺服器設定檔
sudo vim /etc/apache2/apache2.conf
將 AllowOverride 改成 All,有些伺服器還需要修改 AccessFileName 的設定
<Directory /var/www/>
Options Indexes FollowSymLinks (把 Indexes 去掉的話,就會不會顯示目錄)
AllowOverride All
Require all granted
</Directory>
備註: 為了減少效能的影響,儘量對個別資料夾設定會比較好
在 .htaccess 加入最基本的內容
Options -Indexes
保護此目錄下的所有檔案
Deny from all
限制存取,並可以防止盜連網址
RewriteEngine on RewriteCond %{HTTP_REFERER} !^http://andy.revo.so/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.revo.so/fakebook/.*$ [NC] RewriteRule \.(gif|png|jpg|py)$ http://redirect-url [R,NC]
2.
bower
需要先安裝 Node.js,一個事件驅動I/O伺服端JavaScript環境
sudo apt-get install python-software-properties sudo apt-add-repository ppa:chris-lea/node.js sudo apt-get update sudo apt-get install nodejs
以上指令會安裝好 Node.js 以及 npm,用 npm 安裝 bower
sudo npm install -g bower
下載插件
sudo bower install [plugin_name]
列出目前所有插件的位置
sudo bower list --path
3.
git
git 設定
git config --global user.name "Andy Hsu"
git config --global user.email "rastetle13@gmail.com"
前往 github https://github.com/,新增一個 repository
在專案資料夾中建立 repository
git init
git add some_file
git commit -m "first commit"
加入 remote repository
git remote add origin https://github.com/andyhsu5213/cam2u.git
git remote (列出全部的 remote repo)
將檔案上傳到 github
git push -u origin master (git push [remote-name] [branch-name]) (設定 -u 後,之後可以直接 pull 不指定 remote branch)
建立 .gitignore,將不需要版本控制的檔案列在這個文件裡面
簡易範例
# comment
manage.py
*.png
*.jpg
*.gif
基礎指令
git init
git [add file_name] [--all]
git commit -m "commit message"
git rm [file_name]
git rm [file_name] --cache (取消檔案追蹤)
git status
git log
git branch // 列出所有的 branch
git branch branch_name // 新增 branch
git branch -d branch_name // 刪除 branch
git checkout [branch_name] [HEAD]
git checkout [file_name] // 將檔案還原成未修改的狀態
git push
git pull
(取得最新的 commit,但不會切換以及 merge)
(加上 --rebase 參數,會先回復成上次 pull 的 commit,套用更變之後,再加上本地的更變)
git fetch // pull and merge
git clone // init a new repo
git merge source dest
git rebase source dest // 將 source 的 commit 移到 dest 的下方
git reset HEAD^
(還原到上一次 commit,不會留下 commit 過的記錄,但會留下檔案,加上 --hard 參數則連檔案也一併還原)
git revert HEAD (還原倒上一次 commit,但會留下 commit 記錄)
git stash // 丟進暫存區
git stash list // 列出所有暫存區的資料
git stash pop
沒有留言:
張貼留言