我想要做的是,Git:是否可以使用數字在舞臺上添加(或差異)文件?
(spacegraphy) [email protected] spacegraphy-project $ (feature/carts)git status
On branch feature/carts
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)
modified: spacegraphy/carts/tests/test_views.py
modified: spacegraphy/carts/views/cart.py
modified: spacegraphy/functional_tests/test_cartitem_at_product_detail.py
modified: spacegraphy/products/static/js/product_detail.js
no changes added to commit (use "git add" and/or "git commit -a")
當我想看到的spacegraphy/carts/views/cart.py
區別,我要像這樣輸入:
>> git diff 2
(2
因爲spacegraphy/carts/views/cart.py
是第二次在不分級的文件列表)
同樣的,當我想補充spacegraphy/products/static/js/product_detail.js
,我要像這樣輸入:
>> git add 4
會有可能嗎?請任何想法嗎?
是的,這是可能的,但你將不得不編寫自己的shell腳本來解析'git status'的輸出,並找到你想添加的文件的位置,然後在該文件上執行'git add'。你可以嘗試使用'git status',''xargs'和'git'。 – Samundra