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 =
ignore = dirty

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

細說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