#git alias

修改了某些檔案,一次只 commit 其中某幾個檔案


git status

# 看到以下的狀態
On branch develop
Changes not staged for commit:
(use "git add <file>..." to update what will be commited)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: document.json
modified: package-lock.json
modified: package.json
modified: src/app/app.component.html
modified: src/app/app.component.ts
modified: src/app/app.module.ts
modified: src/index.html
modified: src/styles.css

no changes added to commit (use "git add" and/or "git commit -a")

可是我只希望部分檔案加入 staging area,比如寫 component 時很好用,現在只希望加入 src/app/app.component 開頭的兩個檔案: src/app/app.component.htmlsrc/app/app.component.ts

# 原本要這樣加入
git add src/app/app.component.html src/app/app.component.ts

# 現在只要這樣寫
git add src/app/app.component-*