Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run "git status" and just get the filenames

as opposed to the long relative path?

like image 973
myusuf3 Avatar asked Mar 08 '11 20:03

myusuf3


People also ask

What information can you find with git status?

The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. Status output does not show you any information regarding the committed project history.

How do I run a git status?

To check the status, open the git bash, and run the status command on your desired directory. It will run as follows: $ git status.

Why is git status showing all files?

It seems you have created a repo for too many folders. Make sure you create a new repo ( git init , git clone ) only in your project folder. Now everything in this folder will by tracked by git (unless you use . gitignore).


2 Answers

The output of git status --porcelain, designed to be easy to parse in a script, outputs the full paths rather than relative paths regardless of where your current directory is within the tree.

Each line output by git status --porcelain has two leading characters indicating the status of the file (e.g. whether it's untracked, modified, new, deleted, etc.) followed by a space, so if you just want the full paths of everything that would be mentioned in the output of git status you can do:

git status --porcelain | sed s/^...// 
like image 102
Mark Longair Avatar answered Oct 16 '22 17:10

Mark Longair


I think cut is good for this.

git status -s | cut -c4- 
like image 35
earlonrails Avatar answered Oct 16 '22 17:10

earlonrails