How to ignore changes in git submodules

When I was dealing with complex project with some submodules, submodules always get dirty after I configure them independently. This is very common but cause whole git dirty and ugly. Is there a simple way to solve something like this:

On branch master
Your branch is ahead of 'origin/master' by 1 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)

modified: converter/cl2ptx/libclc (untracked content)

The solution is quite simple. After you add your submodules. .gitmodules must be in your repository directory. Edit it and add one more line “ignore = dirty”. The file would be like this:

[submodule "converter/cl2ptx/libclc"]
path = converter/cl2ptx/libclc
url = http://llvm.org/git/libclc.git
ignore = dirty

Problem Solved!!! Enjoy your neat and clean git repository!!

How to Write a Lambda Expression and Callback Function in C

Lambda expression has been supported by many programming languages, but not standard C. By using lambda expression, one can easily do complex job with only the main part of algorithm. For example, one can write a parallel mapping function by lambda without declaring a multi-threading function. Therefore one writes only the essential part of code. The result is a better and simpler way of coding. Continue reading

Kernel Mode 與 User Mode 的概念

為什麼要有 Kernel Mode 與 User Mode?

首先我們先從為什麼要有 Kernel Mode 與 User Mode 談起。大家桌機或者是筆電用的作業系統,不論是 Windows 或者是 Linux,都可以 在同一個時間執行很多程式。 然而,當我們可以執行多個程式,我們如何確保二個程式不會相互干 擾?我們如何確保 A 使用者的程式不會更動 B 使用者程式的變數? 我們如何確保一個使用者不會佔著資源不放手(CPU、RAM…)?我們如何確保一個使用者的程式不會惡意的更動作業系統內部的資料結構以竊取更多的資源?我們如何確保硬體可以被正確地操作? Continue reading

細說git reset和git checkout的不同之處

Those who want to read English version to understand the difference between git reset and git checkout, please go to check the reference [1] at the bottom.

git是一個非常好用的版本控制軟體,但是在使用上偶爾會碰到使用git checkout和git reset,這時候就會想說到底要用哪個才是正確的,簡單的結論是,除非你清楚知道你在做什麼,不然不要使用git reset,大部分的情況都可以不用使用它,它就跟Linux中的 rm指令一樣,不可以隨便亂用,因為一旦使用了就會造成不可還原的影響。

Continue reading