我可以列出当前提交的文件吗? [英] May I list the files of the current commit?

查看:45
本文介绍了我可以列出当前提交的文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下,每次提交文件时,在推送文件之前,我都会列出要检查的文件.我该怎么办?

Imagine that everytime I commit files, before I push them, I'd like to list them to check. How may I do that ?

我尝试过:

git ls-tree -r --name-only master
git ls-files -stage

如果我编辑一个文件,请先add然后再commit.如果我尝试上述代码,它将显示我的所有文件.

If I edit a single file, add then commit it. If I try the above codes, it shows me all my files.

我只想列出将在当前提交时推送的文件.

I want to list ONLY the files that will be pushed on the current commit.

推荐答案

Git diff对此有所帮助.您将使用--name-only标志.要获取当前提交的内容,请使用以下命令:

Git diff to the rescue on this one. You'll use the --name-only flag. To get the contents of the current commit, use this command:

#before stage
  git diff --name-only 
#staged changes before committing
  git diff --name-only --cached
#after committing
  git diff --name-only HEAD^ HEAD

如果要查看提交的次数超过一次,则要推送的文件,则需要指定当前的分支头和远程头.

If you want to see the files that you will be pushing if there is more than one commit, you'll need to specify your current branch head and the head on the remote

git diff --name-only remote/branch branch

这篇关于我可以列出当前提交的文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆