How can I restrict git status to regular files in the current directory only?

前端 未结 4 981
灰色年华
灰色年华 2021-02-05 07:28

I would like to see the status of the current directory. Because there are lots of changes in sub-directories, which I do not want to see, the following command doesn\'

4条回答
  •  萌比男神i
    2021-02-05 07:59

    I believe the answer is no...

    Unless the files are untracked files, submodules, or ignored files. The full documentation for the status command mentions nothing about limiting the output to the current directory.

    However, you might want to consider using the stash command to clean up your working tree. If you stash everything not in your current directory (which requires the --patch option to only stash selective parts), then status will only show what you didn't stash. However, if you use stash multiple times while working, then you should always have a clean working tree and you could avoid this problem to begin with. Each body of work will be packaged up in a separate stash waiting until you are ready to commit it.

    Of course, that doesn't help much with your current situation (aside from using (stash --patch). Another alternative you might want to try is the interactive mode of the add command. Then you can go through all the changed files and selectively add the ones you want (stash --patch works the same way).

    Or, you can use the grep solutions suggested in other answers.

提交回复
热议问题