jesseduffield / lazygit

simple terminal UI for git commands
MIT License
53.67k stars 1.87k forks source link

Toggle hide/show untracked files #982

Open hzwangzi123456 opened 4 years ago

hzwangzi123456 commented 4 years ago

How to hide the untracked files in files?

glvr182 commented 4 years ago

You mean like gitignore?

jesseduffield commented 4 years ago

This can be done at the repo level with the git config. Closing due to staleness

epheien commented 3 years ago

need toggle hide untracked files feature

jesseduffield commented 3 years ago

@epheien do you mean from within lazygit?

epheien commented 3 years ago

@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.

jesseduffield commented 3 years ago

I've updated the issue description for this use case

cas-- commented 2 years ago

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.

image

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?

image

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):

image

I hope this helps in deciding what to do with this issue

dcd-arnold commented 2 years ago

I would like to add that I would like the option to add the untracked file I see.

mark2185 commented 2 years ago

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.

dcd-arnold commented 2 years ago

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.

mark2185 commented 2 years ago

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?

jesseduffield commented 2 years ago

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.

mark2185 commented 2 years ago

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.

jesseduffield commented 2 years ago
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.

mark2185 commented 2 years ago

Yeah, that makes more sense. :smile:

jesseduffield commented 2 years ago

Now we just need that toggle feature!

mark2185 commented 2 years ago

I say we wait for lazydocker to get that and then steal it. :full_moon_with_face:

jesseduffield commented 2 years ago

hahaha

all500234765 commented 2 years ago

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.

jesseduffield commented 2 years ago

@all500234765 would that not be a good candidate for inclusion in the gitignore file?

all500234765 commented 2 years ago

Then it will have merging issues because those files are local and git repo shouldn't know anything about them until commited

StarTerrarium commented 1 year ago

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.

mark2185 commented 1 year ago

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.

StarTerrarium commented 1 year ago

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

AckslD commented 1 year ago

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.

melMass commented 8 months ago

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"
jesseduffield commented 8 months ago

@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.

melMass commented 8 months ago

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"
tbena commented 1 month ago

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.

elig0n commented 3 weeks ago

Is this planned or too difficult to achieve?

JamesMowery commented 3 weeks ago

I'm also following this. Would really like this to be a feature. :)