Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list just the files that would be committed?

Is there any way to get a list of files that will be committed when I type the following?

git commit -m "my changes" 

git status lists too much. I could strip out all the words, but I'd rather not. And I don't want to be told about untracked files.

I've tried

git ls-files -md 

but that doesn't show files that have been recently added, but not yet committed.

I'm looking for the same output you'd get from

svn status -q 

For example $ svn status -q
A file.py
M dir/database.py
M start.py

like image 402
gene Avatar asked Nov 29 '09 03:11

gene


People also ask

How do I list a committed file?

Solution. 2.1 git log to display all the commit_id, the first one is the last commit_id, copy it. 2.2 git show commit_id --name-only to display all the files committed in the specified commit_id. 2.3 Undo the last commit with git reset --soft HEAD~1 , move the mistakenly committed files back to the staging area.

How do I see files before a commit?

If you just want to see the diff without committing, use git diff to see unstaged changes, git diff --cached to see changes staged for commit, or git diff HEAD to see both staged and unstaged changes in your working tree. +1 Yes. git diff . htaccess does what I wanted to achieve.


1 Answers

This is what I was looking for. Thanks to notnoop for the lead I needed. I wanted to post back my solution in case it helps others.

git diff HEAD  --name-only 

Since I intended to do

git commit -s -F mesage.txt 

with the files found in the first line.

My intent is to create a little system that totally ignores the index i.e. that I never need to do git add. (From what I understand, the index is useful when creating patches, which isn't by no means the norm in my workflow.)

like image 92
gene Avatar answered Oct 05 '22 16:10

gene