DEV Community

Discussion on: Turn around your Git mistakes in 17 ways

Collapse
 
netch80 profile image
Valentin Nechayev • Edited

A good intro, just a few notes:

For commands like restore, it is useful to separate paths from options with '--', e.g. git restore -s <commit_id> -- <path1> <path2>. Shell completion relies on it.

For recipe 3, if not to add -m, this opens editor. In a case of multiline commit message (typical for a complex project) this is much handier.

Recipe 9: it's useful to note exceptions to cleaning, like: git clean -dfx -e .vscode.

For recipe 11: git log works with commit ids as well, so, git log -p <id> may suggest what was the branch to restore. Anyway, well, good messages are useful... but I'm regularly encountering the same commit sequence over different branches.

Collapse
 
smitterhane profile image
Smitter

Good notes👍. For recipe 9, I am curious why would I add the -x and then manually add -e. Looks like a lot of work

Collapse
 
netch80 profile image
Valentin Nechayev • Edited

I am curious why would I add the -x and then manually add -e.

This is the case build artifacts (all of them - object files, libraries, autogenerated sources, etc.) are present in the same directory as the working copy. Normally, they are all in .gitignore. Heavy cleaning from build results require deleting all of them. But, if IDE and other locals aren't a level upper, they are to be saved from deletion.

Some comments have been hidden by the post's author - find out more