日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

git: git add --ignore-removal git add --all 区别

發(fā)布時(shí)間:2025/4/16 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git: git add --ignore-removal git add --all 区别 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

遇到的問(wèn)題
在倉(cāng)庫(kù)中刪除文件后,試圖直接用 git add . 將所有刪除工作提交暫存區(qū),結(jié)果遇到了報(bào)錯(cuò):

$ git add .

warning: You ran 'git add' with neither '-A (--all)' or '--ignore-removal',
whose behaviour will change in Git 2.0 with respect to paths you removed.
Paths like '.idea/Wood_Tool.iml' that are
removed from your working tree are ignored with this version of Git.

* 'git add --ignore-removal <pathspec>', which is the current default,
? ignores paths you removed from your working tree.

* 'git add --all <pathspec>' will let you also record the removals.

Run 'git status' to check the paths you removed from your working tree.

經(jīng)過(guò)上網(wǎng)查閱,用 git add --all 解決了問(wèn)題。

進(jìn)一步探究
指令?? ?區(qū)別
git add --ignore-removal <pathspec>?? ?不會(huì) 將刪除操作提交至?xí)捍鎱^(qū)
git add --all <pathspec>?? ?將刪除操作提交至?xí)捍鎱^(qū)

很明顯我們需要的是第二種。

實(shí)驗(yàn)代碼
# 新建倉(cāng)庫(kù)并添加文件
$ git init
Initialized empty Git repository in /media/hok/test/.git/
$ git add .
$ git status
On branch master

Initial commit

Changes to be committed:
? (use "git rm --cached <file>..." to unstage)

? ? new file: ? 1.txt
? ? new file: ? 2.txt
? ? new file: ? 3.txt

# 刪除文件后嘗試用 git add --all
$ rm 1.txt?
$ git add --all
$ git status
On branch master

Initial commit

Changes to be committed:
? (use "git rm --cached <file>..." to unstage)

? ? new file: ? 2.txt
? ? new file: ? 3.txt

# 刪除文件后嘗試用 git add . --ignore-removal,則刪除操作 依然未被 提交至?xí)捍鎱^(qū)
$ rm 2.txt?
$ git add . --ignore-removal
$ git status
On branch master

Initial commit

Changes to be committed:
? (use "git rm --cached <file>..." to unstage)

? ? new file: ? 2.txt
? ? new file: ? 3.txt

Changes not staged for commit:
? (use "git add/rm <file>..." to update what will be committed)
? (use "git checkout -- <file>..." to discard changes in working directory)

? ? deleted: ? ?2.txt
原文:https://blog.csdn.net/JNingWei/article/details/78494478?

《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結(jié)

以上是生活随笔為你收集整理的git: git add --ignore-removal git add --all 区别的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。