Git Discard changes has no impact

I’m sorry, it feels like I sounded inappropriately rude.
I was just struggling with it at the moment, so I found this topic, and seeing how this issue hasn’t changed over a year, I became more frustrated…
Again, sorry.

I agree with other speakers that the current behavior of git about file deletion is inconvenient and not obvious.
User tries to discard all changes, but some of them are left and he can’t get rid of them and does not understand why…

I understand that it seems like it can’t be fixed easily. So maybe it would be helpful if some additional explanation about it be added in the Git in Wappler or in the docs.

It’s better if Wappler doesn’t do anything unconventional.

My suggestion is when clicking the discard all changes icon to show a popup if there are new untracked files informing that those files can’t be discarded and should be deleted manually. This behaviour would also apply when selecting multiple files being one or more of them new untracked files.

Add a new contextual option called delete file that will do a regular delete. The delete file will appear for untracked and tracked files, while the discard changes should appear only for tracked files. Users need to understand that they are two different actions.

Why this approach? Because this is what is actually happening behind the curtains and it’s what people will expect if at some point they decide to move to the CLI or another git tool.

If Wappler messes with the standard behaviour people could perform the same action in another tool expecting for the same Wappler behaviour and who knows…maybe one day they commit to a public repository a newly created file they expected to delete with a discard all containing their database credentials or an API key for their Amazon account and get a nice invoice for mining monero.

1 Like

I wasn’t aware of this. From what I know, sourcetree and VSCode both just give a discard option for untracked/new files.
Maybe that is the expected behavior for UI?

I don’t mind a separate context action, as long as the task gets done.

1 Like

The problem is with the mass action. If you try to discard a single (new)file I guess the option won’t appear but only the delete. But with multiple files I assume the decided to call it discard and maybe present a warning.

Gitkraken doesn’t present the discard action for a single file if it’s new and git doesn’t know about it(uncommitted). It displays the delete option.

1 Like

The Gitkraken “discard all changes” does present the following warning, and does remove the new files it doesn’t know about, which to my mind is very clear and precise, and leaves no ambiguity.


In Wappler I can right click a new file, and from context select “discard changes”, then click yes in the dialog “are you sure you want to revert this file”, but nothing happens, the new file remains in place, which would seem like a bug to me. If it is not a bug then what is “discard changes” meant to do for new files?

1 Like

If you read again my post you will see that I mentioned that gitkraken doesn’t allow discarding single new files. That is because git doesn’t allow it. You can verify this by trying to discard any single new file.

The “discard all” functionality performs two actions in one go: discard git changes and delete files. But that is a bad practice for the reasons I mentioned before plus those mentioned already by george.

It’s better to stick to standards so people can learn the basic concepts of git that can be applied in any context even if that means one more click.

Thanks Jonas, I did read that in your post and wasn’t suggesting you were incorrect, my comment was about discard all changes also removing new files in Gitkraken, and the warning presented.

I thought git-clean removed files that are not under version control, which is what we are referring to, so it seemed to me that GIT supports it, unless I am misunderstanding things.

In any case it doesn’t change the fact that orphaned files can be left behind in Wappler as I pointed out, so to me at the very minimum you should not be able to discard new files, and users should be warned of that or follow your suggestion, I personally find this more confusing, but will let the experts decide what is best.

2 Likes

Git clean is a command that deletes files from your working tree in a recursive manner but I don’t think gitkraken uses this command to perform the “discard all” action as it’s quite a powerful command that could really mess up your project in horrible ways. It evens allows a flag to perform a test run that will show you what files will be deleted without actually doing it.

I get you point, really. I personally do discard all changes in gitkraken constantly with confidence because I know what’s happening. But I also use git cli and I know that discarding changes via the cli doesn’t delete new files so I have to go and delete them later. But if someone doesn’t know this he might commit something unintended to a public repo at some point because he thought discarding meant deleting new files.

So my advice wasn’t intended for people that know git, but for those that don’t which is still a huge amount of people in wappler.

1 Like

git-clean can be a very dangerous command since it removes all the files recursive which are not known by Git. This means that there is no version control on the files that are removed and there is no way to undo that action and it doesn’t discard any changed made in Git. The discard changes only affects the files that are versioned and leaves the unversioned files untouched.

We simplified Git a bit in Wappler, normally you first need to add files to Git before you can commit them, we included that in a single step, so the uncommitted changes show the files that are versioned and also the one that aren’t in Git.

Each Git client handles things in its own way, there is no specific git command for discard changes. For discard changes Wappler actually does a git checkout and for the discard all changes it does a git reset --hard.