over 2 years ago

## [Git] How to maintain local commits

Today I was be asked by my colleague "How to maintain (Git) commits which is local only such configurations?".

Commits like these should always be with the development branch, however, we don't want them to be pushed back to repo.

The simplest way is to put those file paths in .gitignore file - a text file indicates Git to ignore files from revision tracking. However, sometimes we can't just ignore them from revisioning, ex: config.php. We need them to be tracked by Git, and also part of the changes stay in local at the same time.

For this circumstance, I'll maintain two branches locally, one is master and another is config. Both of them are setting upstream to origin/master, but the config branch will never push commits back to repo, instead, it pulls only. And the config branch is always leading some commits which you don't want them to be pushed back.

For further explaination, let's create the config branch and set the its upstream to origin/master. ↓↓↓

And the history tree will looks like this after checked-in several local commits.

The local commts may contain the necessary configurations which make your development enviroment works, so we coding/developing on the branch config. This is the tree graph it looks like after we've done some works. (remember we still on branch config which contains both local commits and works)

Now, assume we've done some works (w0, w1), and want then to be pushed back to repo. Here is the instructions: checkout the master branch, pick up the works we've done from config branch (NOTE: be avoid the local commits), then push them back.

Then check-out config branch and pull again.

Finally we got works to be pushed back and local commits still stay in local.

over 2 years ago

(更新 2014/07/24 YouTube 已經取消數量 100 的限制)

寫個跟程式沒有太大關係的小小發現。

YouTube 有個好用的功能，就是在所有播放器上都有個小小像是「讚」的按鈕，按下去後會保存到「喜歡的影片」中，日後可以瀏覽你所點過讚的影片。這功能或許大家還不陌生，但是有個小小的缺點，「喜歡的影片」數量會有 100 個的限制，較早先所加進來的影片會被新加進來的影片推出清單之外，以確保清單中永遠只保留最新 100 個影片。這難免會有點小小的遺撼，因為我們可能無法記錄 n 年前甚至 n 個月前喜歡過哪些影片。

以下是詳細的做法。

在「播放清單」列表裡點擊「喜歡的影片」進入。↓↓↓

這時候會看到「喜歡影片」的列表，請把注意力移到網址列。↓↓↓

我們把網址列“.../playlist?list=”之後那一串字複製下來，以上面範例中來說，那一串字便是「LL6PU8SUI3qKJ29mv10IwCYA」。