日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

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

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

遇到的問題
在倉庫中刪除文件后,試圖直接用 git add . 將所有刪除工作提交暫存區(qū),結果遇到了報錯:

$ 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)過上網(wǎng)查閱,用 git add --all 解決了問題。

進一步探究
指令?? ?區(qū)別
git add --ignore-removal <pathspec>?? ?不會 將刪除操作提交至暫存區(qū)
git add --all <pathspec>?? ?將刪除操作提交至暫存區(qū)

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

實驗代碼
# 新建倉庫并添加文件
$ 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,則刪除操作 依然未被 提交至暫存區(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ù)字化實踐50位技術專家共同創(chuàng)作,文字、視頻、音頻交互閱讀

總結

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

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