X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=pep-git.txt;h=d215a585978b640279a538aebed908cc22eeeb05;hb=ff0aeb35aaf670d3240e79de4c0fca72172a66d3;hp=d42184b4fbda81f396ef57356f5bb91e2caa3c2f;hpb=e58b976218dba56b2eaa767d09d4ddb41186d0f8;p=git-wiki.git diff --git a/pep-git.txt b/pep-git.txt index d42184b..d215a58 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -496,7 +496,25 @@ 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 preserving them. + +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 new commits +over non-committed files. + +But there are commands that do exactly that - overwrite files in the +working tree. Commands like ``git checkout $PATHs`` or ``git reset +--hard`` silently overwrite 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, remove. But save your changes in git database, +either commit changes or at least stash them with ``git stash``. Merge or rebase? @@ -567,10 +585,15 @@ Git has a builtin merge strategy for what Python core developers call $ git merge -s ours v1 # null-merge v1 into v2 -ReReRe -====== +Advanced configuration +====================== -https://git-scm.com/book/en/Git-Tools-Rerere +Line endings +------------ + +Git has builtin mechanisms to handle line endings. + +TODO: describe crlf configuration and .gitattributes. Advanced topics @@ -587,15 +610,10 @@ Staging area aka index is a distinguishing feature of git. See Wiki. -Advanced configuration -====================== - -Line endings ------------- - -Git has builtin mechanisms to handle line endings. +ReReRe +====== -TODO: describe crlf configuration and .gitattributes. +https://git-scm.com/book/en/Git-Tools-Rerere Database maintenance