Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
292 views
in Technique[技术] by (71.8m points)

git - 如何显示已上演的更改?(How do I show the changes which have been staged?)

I staged a few changes to be committed;

(我上演了一些改变来承诺;)

how can I see the diff of all files which are staged for the next commit?

(如何查看为下一次提交而暂存的所有文件的差异?)

I'm aware of git status , but I'd like to see the actual diffs - not just the names of files which are staged.

(我知道git状态 ,但我想看到实际的差异 - 而不仅仅是分阶段文件的名称。)

I saw that the git-diff(1) man page says

(我看到git-diff(1)手册页说)

git diff [--options] [--] […]

(git diff [--options] [ - ] [...])

This form is to view the changes you made relative to the index (staging area for the next commit).

(此表单用于查看您对索引所做的更改(下一次提交的暂存区域)。)

In other words, the differences are what you could tell git to further add to the index but you still haven't.

(换句话说,差异是你可以告诉git进一步添加到索引但你还没有。)

You can stage these changes by using git-add(1).

(您可以使用git-add(1)暂存这些更改。)

Unfortunately, I can't quite make sense of this.

(不幸的是,我无法理解这一点。)

There must be some handy one-liner which I could create an alias for, right?

(必须有一些方便的单行,我可以创建一个别名,对吗?)

  ask by Frerich Raabe translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It should just be:

(它应该只是:)

git diff --cached

--cached means show the changes in the cache/index (ie staged changes) against the current HEAD .

(--cached表示针对当前HEAD显示缓存/索引(即分阶段更改)中的更改。)

--staged is a synonym for --cached .

(--staged--cached的同义词。)

--staged and --cached does not point to HEAD , just difference with respect to HEAD .

(--staged--cached不指向HEAD ,只是与HEAD有所不同。)

If you cherry pick what to commit using git add --patch (or git add -p ), --staged will return what is staged.

(如果您使用git add --patch (或git add -p )来挑选提交内容,则--staged将返回正在--staged内容。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...