Open hzwangzi123456 opened 4 years ago
You mean like gitignore?
This can be done at the repo level with the git config. Closing due to staleness
need toggle hide untracked files feature
@epheien do you mean from within lazygit?
@epheien do you mean from within lazygit?
yes, I need not change git config and simply toggle show / hide untracked files, for example:
git status -uno # hide
git status # show
Some git client has this feature, such as Fork.app on macOS.
I've updated the issue description for this use case
I was just trying out lazygit and this was an immediate issue since I had been testing npm apps in a repo but not made any commits so node_modules was still hanging around and the entire listing for that directory made the Files panel unusable upon first opening.
I thought that having a hide untracked files setting would be the solution for me however there are perhaps some UX improvements that could help as well.
Firstly I found the discussion in #1712 about how to navigate panels and it was non-obvious to me to use Enter to collapse a dir, I kept trying arrow keys. Also how do you navigate to top or bottom of the file panel since PgUp or PgDn navigates in the change panel.
One small improvement might be for untracked directories (or very long directory listings) to be collapsed by default?
A further improvement would be to sort by tracked first and prefixing dirs with ??
or M
. This would emulate the short git status. (side-note I feel dot prefix files really should sort first):
I hope this helps in deciding what to do with this issue
I would like to add that I would like the option to add the untracked file I see.
I would like to add that I would like the option to add the untracked file I see.
Add it as in "stage it"? Pressing space
should do it.
hi @mark2185, thanks for getting back to me. I have set
[status]
showuntrackedfiles = no
in my git config. I don't want to see untracked files in git status
on command line. I add the files I need (seeing all files on the commandline with ls
).
However, I do not see untracked files in lazygit
. My guess is, lazygit
picks that setting up. But I don't see all or untracked files in lazygit
, hence I can't add them on demand. I leave lazygit
, add the files and start lazygit
again to continue to work on the commit. I would like to able to switch view of (un-)tracked files within lazygit
so I don't have to leave to the command line an back. I hope that explanation clears things up a bit.
Oh yes, that clears things up quite a bit.
@jesseduffield maybe the showuntrackedfiles
setting should only change the initial state of the filter?
Those with said setting will have the filter Show only staged files
, others will have it set to no filter
, and the Files
pane should always show all the files and then filter them out if needed?
I agree about showuntrackedfiles determining the initial state, but in this case Show only staged files
won't do because we still want to show unstaged, tracked files.
Oh yeah, forgot about that tiny detail.
Well then, having the filters togglable? I know toggles aren't yet a feature, but hey.
[X] Show staged files
[X] Show unstaged files
[X] Show tracked files
[X] Show untracked files
But it does seem like it complicates stuff more than it does simplify.
I'm thinking we could have a 'show staged / show unstaged / show all' option as well as a separate toggle for 'show untracked'. So we'd have this logic: | staged | unstaged | all | |
---|---|---|---|---|
show untracked | hide untracked | show untracked | show untracked | |
hide untracked | hide untracked | hide untracked | hide untracked |
Where the column headers are for the staged/unstaged/all option and the row headers are for the 'show untracked' toggle, and the cells in the middle describe whether we actually show untracked files given a combination of the two options.
Yeah, that makes more sense. :smile:
Now we just need that toggle feature!
I say we wait for lazydocker
to get that and then steal it. :full_moon_with_face:
hahaha
But what about hiding specific untracked folders that won't be commited in any case? Or hiding only untracked files inside a specific folder? For example: I have a project that I am working on, and I have lots of testing data, meta files, png, txt, etc... It can pile up to a several GBs with thousands of files. Navigating with this pile to stage specific file is quite hard. And most of the time my day starts with me closing all folders except source code, since it has no similar problems (:
I have following structure:
ImportantFolderRoot/ImportantFolder1/,,, ImportantFolderRoot/ImportantFolder2/... ImportantFolderRoot/ImportantFile1 ImportantFolderRoot/ImportantFile2 ImportantFolderRoot/UnstagedTestingFile1 ImportantFolderRoot/... ImportantFolderRoot/UnstagedTestingFolder/...
and so on.
@all500234765 would that not be a good candidate for inclusion in the gitignore file?
Then it will have merging issues because those files are local and git repo shouldn't know anything about them until commited
Chiming in to describe my use-case for this. I store my config dotfiles in a bare repo at ~/.dotfiles
, and typically interact with it like lazygit --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"
. Given that the entire home directory is the worktree, I have status.showUntrackedFiles
disabled for this repo.
Whenever I want to add a new file to the repo I find myself reaching for regular git to add it as I can't find a way to do that in lazygit.
I don't necessarily need or even want a toggle to show untracked files as that will certainly break things in my situation as it contains every file in my home directory. I simply need a way to add a currently untracked file - whether by providing a fill path or navigating to it and selecting it somehow, the mechanism wouldn't matter a whole lot to me. It would just let me not reach for raw git.
It would just let me not reach for raw git.
Would running a custom command through :
suffice?
Just :git add <file>
, but just to point out that there is no autocompletion.
I sort of assumed that wouldn't give me a lot of benefits because I thought I'd need to add in the whole --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"
again to that command.. But it turns out I was wrong.
:git add ~/test
does indeed work as expected - so this gets me basically where I wanted, just without ideal UX. Thanks a bunch for the suggestion
as well as a separate toggle for 'show untracked'.
I would love this! I often find myself in cases where I only want to see tracked files but I don't yet want to add the untracked files to gitignore.
I'm personally doing this but LazyGit needs to be restarted to refresh, could I refresh lazyy without restarting it?:
customCommands:
- key: "u"
command: "git config status.showUntrackedFiles {{.Form.Value}}"
context: "global"
prompts:
- type: "menu"
title: "Show untracked?"
key: "Value"
options:
- value: "yes"
name: "Yes"
description: "Show untracked files"
- value: "no"
name: "No"
description: "Hide untracked files"
@melMass try pressing shift+R from the files view after running that command, it should refresh the files and that should make use of the new git config value.
Thanks @jesseduffield ! The values of my custom commands were wrong (it's either normal
or all
not yes
), but I still can't seem to be able to refresh the file list (I tried shift R and r which is what the help shows):
customCommands:
- key: "u"
command: "git config status.showUntrackedFiles {{.Form.Value}}"
context: "global"
prompts:
- type: "menu"
title: "Show untracked?"
key: "Value"
options:
- value: "normal"
name: "Normal"
description: "Show untracked files"
- value: "all"
name: "All"
description: "Show untracked files (individual files in directories)"
- value: "no"
name: "No"
description: "Hide untracked files"
Any updates on this? The solution in the comment above works but feels hacky and requires re-opening lazygit. I also tried both r and shift+r from the help and it did not work.
How to hide the untracked files in files?