X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=pep-git.txt;h=93407034b8dcdebefa888e4e1d578c20c88e848a;hb=edb46a009e29d8e35884a05e9b827109a2577773;hp=d42184b4fbda81f396ef57356f5bb91e2caa3c2f;hpb=e58b976218dba56b2eaa767d09d4ddb41186d0f8;p=git-wiki.git diff --git a/pep-git.txt b/pep-git.txt index d42184b..9340703 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -496,7 +496,26 @@ of merge. See the discussion `How to revert a faulty merge One thing that cannot be undone ------------------------------- -"Commit early, commit often". +Whatever you undo, there is one thing that cannot be undone - +overwritten uncommitted changes. Uncommitted changes don't belong to +git so git cannot help with them - no way. + +Most of the time git warns you when you're going to execute a command +that overwrites uncommitted changes. Git warns you when you try to +switch branches with ``git checkout``. It warns you when you're going +to rebase with non-clean working tree. It refuses to pull commits over +non-committed files. + +But there are commands that designed exactly for that - overwriting +files in the working tree. With commands like ``git checkout $PATHs`` +or ``git reset --hard`` git silently overwrites files including your +uncommitted changes. + +With that in mind you can understand the stance "commit early, commit +often". Commit as often as possible. Commit on every save in your +editor or IDE. You can edit your commits before pushing - change, +reorder, combine. But save your changes in git database, either in +commits or at least in stashes. Merge or rebase?