Today I learned you can show the git status for a specific directory simply by specifying it. e.g., for the current directory:

git status .

#git #dev #devTips

@aral Not just folders, but files too!

Edit: Wait no, I was thinking of git diff ^_^

@aral so git status is the current dir and down and git status . doesn’t recurse down?
@shanselman @aral i think you want git log <dir> or git log . if in that dir already
@shanselman That’s the effect I’m seeing :)
@aral @shanselman hmm, I just checked that, and I see that it still shows me the same thing in case of using "git status" and "git status ."
However, when I do "git status <folder>" it is in fact showing changes from this folder only, ignoring changes from outside of it.
@shanselman "git status" is the entire repo you're in. If you're in the repo root, "git status ." does the same (root and down). But if you're in a subdir, "git status ." is just that subdir and down, not the entire repo. I use that a lot, quite helpful to focus on things.
@aral This is why I think that 'git status' is the best argument for using a Git GUI. Showing current live status is something GUIs can be *so* good at. And they can help in code navigation (get me back to that spot where I just made that other change). Every other Git command (except maybe merge/diff) is probably better on a CLI for a frequent user.
I was gonna "oh, great, did you know you can also..." and then I saw it's Aral. You likely know more of that crap than I do :)
@aral That's part of git status - but it shows me the status of my current repo, including in parallel directories. Might be (likely is) a configurable item, of course.
@aral My mind was blown when I found out `git checkout -` which checks out the previous branch, like `cd -`
@aral `git log <file name>` is great for looking at all commits that have touched a particular file too!

@mapdirective

@aral

Also try the ’git log -L/start/,/end/:file’ option for the history of a single function or block.

@mapdirective Nice; didn’t know that either (what I don’t know about git far outstrips what I do know) :)

@aral
As this thread is turning into a "git options you might not know" free-for-all, I'd like to mention my personal favourites: ’git add -p’, which makes the "add, then commit" workflow actually make sense; and ’git rebase -i’, which can re-order your commits to "tell a story" which is more-readable, before you raise them as a PR (makes more sense with git add -p).

And just for fun: have a read through ’git help rev-parse’. If you haven't before, you're bound to find something useful in there

@aral oh wow! Sometimes we miss the obvious right before our eyes, huh?
@aral another fun one is ‘got -S <search-term>’ which shows you commits where the search term was present in the commit diff
@aral thanks using git for years never knew that was possible.
@Schrooms You’re welcome; and ditto :)
@aral One of the things I like about the fish shell is that it shows the current branch in the prompt by default.
@aral also helpful is "git status -uno ." which shows you status of files but ignores unknowns (you know... the ones you failed to add to .gitignore).