jesseduffield / lazygit

simple terminal UI for git commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option to stash untracked changes

ajhynes7 opened this issue · comments

Hello, thanks for building this great tool.

Sometimes I'd like to stash work which includes new files, but I couldn't find an option in lazygit to stash untracked changes.
It'd be helpful if one of the stash options was "include untracked changes".

I believe this is equivalent to the command:

git stash -u

I do believe that option is currently in master, could you give it a spin?

It should be under the Stash options, triggered by S (note: uppercase) in the Files pane by default.

Sure, I built the executable on master and tried it like you suggested. I see some more stash options, but not one for stashing untracked changes:

image

You're right, I must've misremembered.

Could you explain upon what is the use case of stashing untracked changes? The only thing I can think of is that you have files of the same name on a different branch and then checking out that branch might cause conflicts, otherwise the untracked files shouldn't clash with anything.

It's not that they clash, but when I switch branches to work on something else I like to stash everything in my working directory. It keeps the work logically separated, and it prevents accidentally committing an unrelated file to a branch.

Alright, fair enough.

Would you like to take a shot at implementing it?

The rest of the subcommands were added in #1870 which you can use as a reference point, stashing untracked changes would require:

  • adding a new mapping in pkg/gui/controllers/files_controller.go
  • adding a callback function in pkg/commands/git_commands/stash.go.

If it isn't your cup of tea, feel free to let us know and someone will implement it :)

Sure I can give it a shot!

ezoic increase your site revenue