相关疑难解决方法(0)

如何从Git的暂存区域中删除单个文件,但不将其从索引中删除或撤消对文件本身的更改?

情况:我有一个Git存储库,其中包含已存在于索引中的文件.我对几个文件进行了更改,打开Git并使用"git add"将这些文件添加到我的临时区域.

问题:如何从暂存区域中删除其中一个文件但不将其从索引中删除或撤消对文件本身的更改?

git version-control staging

1177
推荐指数
10
解决办法
59万
查看次数

为什么有两种方法可以在Git中取消暂存文件?

有时,git建议git rm --cached取消暂存文件git reset HEAD file.我什么时候应该使用哪个?

编辑:

D:\code\gt2>git init
Initialized empty Git repository in D:/code/gt2/.git/
D:\code\gt2>touch a

D:\code\gt2>git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       a
nothing added to commit but untracked files present (use "git add" to track)

D:\code\gt2>git add a

D:\code\gt2>git status
# On branch master
#
# Initial commit
#
# Changes to …
Run Code Online (Sandbox Code Playgroud)

git git-reset git-rm

1109
推荐指数
13
解决办法
101万
查看次数

如何从git临时区域中删除文件?

我在我的本地仓库中对我的一些文件进行了更改,然后我做git add -A了我认为在暂存区域添加了太多文件的情况.如何从暂存区域删除所有文件?

在我这样做之后,我会手动做git add "filename".

git

456
推荐指数
12
解决办法
38万
查看次数

什么是“git restore”命令,“git restore”和“git reset”有什么区别?

当我想取消暂存文件时,我所有的 Git 教程都显示如下内容:

$ git add *
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    renamed:    README.md -> README
    modified:   CONTRIBUTING.md
Run Code Online (Sandbox Code Playgroud)

此提示告诉我们git reset用于取消暂存文件。

但是,在我的终端中,我看到:

git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
    renamed:    cat.js -> catcat.js
    renamed:    tolendo.gogo -> tolendo.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    readme (copy).md
    tolendo (copy).txt
    zing (copy).html
Run Code Online (Sandbox Code Playgroud)

我的终端告诉我使用,git …

git restore git-reset unstage

107
推荐指数
4
解决办法
8万
查看次数

标签 统计

git ×4

git-reset ×2

git-rm ×1

restore ×1

staging ×1

unstage ×1

version-control ×1