[v] Basic Git Branching & Merging

這是 Git 官方文檔,寫得非常簡明易懂
https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging

Atlassian( 出品 GitBucket, JIRA 等服務的公司) 的文檔,也可以參考看看
https://www.atlassian.com/git/tutorials/using-branches


下面則是我過去做的一些簡單的 git 指令筆記


http://gogojimmy.net/2012/02/29/git-scenario/

$ git checkout -b new-branch `git rev-list --max-parents=0 HEAD`

切回第一個 commit,再開一個新的 branch (new-branch)

$ git checkout branch-1
切換到叫做 branch-1 的 branch

$ git branch -D branch-2
在其他 branch 砍掉一個叫做 branch-2 的 branch
http://stackoverflow.com/questions/2003505/delete-a-git-branch-both-locally-and-remotely

$ git log
進入commit清單,每個commit後面有獨一無二的commit hash key, 按 q 跳出。

$ git reset --hard <commit hash key>
回到指定的 git commit, 並讓你的 local code 和 local history 跟那個 commit 一模一樣...

如果要避免下面的問題

“It will make your local code and local history be just like it was at that commit. But then if you wanted to push this to someone else who has the new history, it would fail.”

我們可以用...
$ git reset --soft <commit hash key>

"It will make your local files changed to be like they were then, but leave your history etc. the same."

http://stackoverflow.com/questions/3639115/reverting-to-a-specific-commit-based-on-commit-id-with-git

$ git checkout <commit hash key>
只是要切回過去某個 commit, 之後還要切回來...

http://stackoverflow.com/questions/4114095/revert-git-repo-to-a-previous-commit

在 github 上設 repo 後,在 terminal 中輸入 $ git clone [git repo網址],就可以把 github repo 傳回 local, 兩邊的 repo 從此連在一起。

local repo 要換位置的話,直接 ctrl-x/ctrl-v 貼到目標檔案夾即可。原因是該 local repo 中有隱藏檔 .git 標示連接的 git repo

要 undo git add 就用 git reset

[v] 常見的 HTTP Request Code

常見

2XX Success

200 OK
The request was handled successfully.

3XX Redirection

302 Found
The requested resource has changed temporarily. Usually results in a redirect to another URL.

4XX Client Error

400 Bad Request

403 Forbidden

404 Not Found
The requested resource cannot be found.

5XX Server Error

500 Internal Server Error
The server has encounter a generic error.

502 Bad Gateway

503 Service Unavailable

504 Gateway Timeout

冷知識

451 Unavailable For Legal Reasons
《華氏451》的典故,因為法律因素被禁,比如政府進行內容審查。

[v] Font Awesome 實作 + 改顏色

Gemfile

gem "font-awesome-rails"

application.css.scss

@import "font-awesome"

index.html.erb

<%= link_to cancel_upvote_post_path(post), method: :delete do %>
  <i class="fa fa-heart fa-lg" aria-hidden="true"></i>
<% end %>

<i class="fa fa-heart" aria-hidden="true"></i> 可以叫出預設版本的實心愛心
<i class="fa fa-heart fa-lg" aria-hidden="true"></i> 可以讓愛心變大 33%
其他關於大小的參數還有 fa-2x, fa-3x......等

posts.scss 因為上一步 class="fa fa-heart fa-lg", 我們取 fa-heart 來改 CSS

.fa-heart {
  color: #ff4d4d;
}

我們就得到一顆紅色的實心愛心了 <3