Git:僅列出“未跟蹤”的檔案(還有自定義命令) - Git: list only “untracked” files (also, custom commands)
問題:
Is there a way to use a command like git ls-files
to show only untracked files?有沒有辦法使用像git ls-files
這樣的命令來只顯示未跟蹤的檔案?
The reason I'm asking is because I use the following command to process all deleted files:我問的原因是因為我使用以下命令來處理所有已刪除的檔案:
git ls-files -d | xargs git rm
I'd like something similar for untracked files:對於未跟蹤的檔案,我想要類似的東西:
git some-command --some-options | xargs git add
I was able to find the -o
option to git ls-files
, but this isn't what I want because it also shows ignored files.我能夠找到git ls-files
的-o
選項,但這不是我想要的,因為它還顯示被忽略的檔案。 I was also able to come up with the following long and ugly command:我還想出了以下又長又醜的命令:
git status --porcelain | grep '^??' | cut -c4- | xargs git add
It seems like there's got to be a better command I can use here.似乎必須有一個更好的命令我可以在這裡使用。 And if there isn't, how do I create custom git commands?如果沒有,我該如何建立自定義 git 命令?
解決方案:
參考一: http://stackoom.com/question/Fwtd參考二: Git: list only “untracked” files (also, custom commands)
「其他文章」
- 用 JavaScript 計算昨天的日期 - Calculate the date yesterday in JavaScript
- 允許保留 2 位小數 - Allow 2 decimal places in
- 在 Android 上防止螢幕旋轉 - Prevent screen rotation on Android
- 如何更新 RecyclerView 介面卡資料 - How to update RecyclerView Adapter Data
- 日曆重複/重複事件 - 最佳儲存方法 - Calendar Recurring/Repeating Events - Best Storage Method
- (13:許可權被拒絕)連線到上游時:[nginx] - (13: Permission denied) while connecting to upstream:[nginx]
- 如何使用 git 檢查 GitHub 拉取請求? - How can I check out a GitHub pull request with git?
- 正則表示式:刪除包含“幫助”等的行 - Regex: Remove lines containing “help”, etc
- >>>和>>之間的區別 - Difference between >>> and >>
- JavaScript 中反引號 (`) 的用法 - Usage of the backtick character (`) in JavaScript
- C 模板typedef - C template typedef
- 僅新增非空白更改 - Add only non-whitespace changes
- Python中exit()和sys.exit()之間的區別 - Difference between exit() and sys.exit() in Python
- Git:僅列出“未跟蹤”的檔案(還有自定義命令) - Git: list only “untracked” files (also, custom commands)
- 谷歌使用什麼資料庫? - What database does Google use?
- 在CLR中投放與使用'as'關鍵字 - Casting vs using the 'as' keyword in the CLR
- 值對的 Java 集合? (元組?) - A Java collection of value pairs? (tuples?)
- 'git 責備' 有什麼作用? - What does 'git blame' do?
- 螞蟻警告:“'includeantruntime'未設定” - ant warning: “'includeantruntime' was not set”
- 如何在不等待的情況下安全地呼叫 C# 中的非同步方法 - How to safely call an async method in C# without await