## Commit binary 檔案到 Git 之前請三思

### 前言(廢話很多)

git rm fileA

git rm --cached fileA

### 當你要 commit binary 檔案到 Git 上面前請先三思！

Don't ever commit binary files to Git! Or what to do if you do.

Git is a great distributed version control system. It's fantastically for easily storing changed to text files wherever you are, and then easily copying them up to a server or servers or sharing them with your friends locally.

Git 是很棒的分散式版本控制系統。他很輕易地儲存了你位於文字檔案的變更的「位置」(i.e.時間點)，然後簡單地複製到一或多個伺服器，甚至在本地端分享給朋友。

Avoid binary files
"Text files" is the key here. It easily lets you see textual changes. But this function is useless for binary data. Data about changes in binary files just makes the commits impossible to read.

There is another very good reason for keeping binary files out of your repository: They are usually much bigger. Images, videos and compiled binaries are all much bigger than text files. If you commit them to your repository, the size of your repository will become much larger.

This matters not because storage is expensive - it's not. It matter because the point of using a distributed VCS is that it makes it cheap and easy to clone and navigate. You want to be able to spin up a new machine and copy the repository as quickly as possible. You want to be able to switch branches as quickly as possible. If you commit any significant number of binary files you will see all of these tasks slow down considerably.

It's important to never commit binary files because once you've commit them they are in the repository history and are very annoying to remove. You can delete the files from the current version of the project - but they'll remain in the repository history, meaning that the overall repository size will still be large.

(按：要往回刪除那些 binary files，除了麻煩之外也有危險性)