Any 3rd party tool that alerts me if I have accidentally uncommitted stuff on my local Git repository?

6 months ago by ZILtoid1991 to c/learn_programming

I often forget to push a few things depending on how Git decides to label my work. Today it labeled a move as a file deletion and add, and only the deletion is present on the upstream, and now the upstream doesn't even compile properly. And I don't want to pull out my hair to resolve yet another conflict, because the only help with Git I can get is jUsT reAD ThE WhoLE maNUaL.

One other thing is that I refuse to use VSCode, especially since they're pushing AI slop code generation so much, and I use KATE instead.

CameronDev 6 points 6 months ago

The problem is that uncommited files in the repo isnt unusual, often people have test files or logs, that you dont want to commit.

I personally use git gui, which will show all the files that arent committed, so that may be a solution for you.

path: 0 23464243, hotness: undefined, score: 6, children: 4
ZILtoid1991 6 points 6 months ago

Then I add those to .gitignore, so I won't forget the files I need to commit, so I don't have to dive through AI slop articles about git to resolve merge conflicts (often things that should have been automatically resolved, except someone didn't have basic common sense).

path: 0 23464243 23464396, hotness: undefined, score: 6, children: 3
CameronDev 2 points 6 months ago

.gitignore is good for stuff that will always be there, but is less good for small one-off files and other detritus.

But if your happy maintaining .gitignore correctly, git add . before commit and youll never miss a file again. You may accidentally commit a secrets file, but thats a different problem for a different day.

path: 0 23464243 23464396 23464853, hotness: undefined, score: 2, children: 2
Valmond 2 points 6 months ago

You can git add even if the file is 'listed' in the .gitignore though? Maybe use -f IIRC

path: 0 23464243 23464396 23464853 23465216, hotness: undefined, score: 2, children: 1
CameronDev 3 points 6 months ago

Doesnt seem so:

But -f works:

path: 0 23464243 23464396 23464853 23465216 23466057, hotness: undefined, score: 3, children: 0
onlinepersona 4 points 6 months ago

Add a prepush hook that checks if git status is clean (or some other gir command that lists uncommitted files). If it is, either fail straight away of make the hook interactive and ask whether it's ok or something.

Maybe https://pre-commit.com/ has something already.

path: 0 23464553, hotness: undefined, score: 4, children: 0
InEnduringGrowStrong 4 points 6 months ago

I just do git status before and after commits

path: 0 23464576, hotness: undefined, score: 4, children: 0
learn_programming
learn_programming

@programming.dev

login for more options
2254
161
63

Posting Etiquette

  1. Ask the main part of your question in the title. This should be concise but informative.

  2. Provide everything up front. Don't make people fish for more details in the comments. Provide background information and examples.

  3. Be present for follow up questions. Don't ask for help and run away. Stick around to answer questions and provide more details.

  4. Ask about the problem you're trying to solve. Don't focus too much on debugging your exact solution, as you may be going down the wrong path. Include as much information as you can about what you ultimately are trying to achieve. See more on this here: https://xyproblem.info/

Icon base by Delapouite under CC BY 3.0 with modifications to add a gradient

go to feed...