diff --git a/Workflow for documentation production in OSM.md b/Workflow for documentation production in OSM.md index 453fb4654b6f63c074971179ab05ed5757d9e20c..7069c646998d7b18f299c0f87202227f51bd3d07 100644 --- a/Workflow for documentation production in OSM.md +++ b/Workflow for documentation production in OSM.md @@ -110,6 +110,25 @@ Then create a branch and move to it in order to continue. In this example, we wi git checkout -b BranchNewSection ``` +#### NOTE: What to do if you committed changes to master by mistake + +In case you forgot to create your branch (or moving to it) and made a number of commits directly to your `master` branch by mistake, you will need to use a procedure to move them to a branch, or you will be unable to work with you remote origin. + +To achieve it, you can still following some steps to fix your Git history and move the commits to the right place. + +Note that **this procedure needs to be followed exactly as it is described** or might lead to unintended loss of commits. In particular, you should understand that: + +- You are **rewriting** your Git history and, therefore, might delete wrong entries if you make any mistake. Please read these steps carefully and follow them accurately. +- Any changes not committed before starting this procedure. If they are relevant for your, you should commit them (to `master`) as well. + + As said, you can follow this procedure (assuming that you start in your `master` branch): + +```bash +git branch newbranch # Create a new branch, saving the desired commits +git reset --hard origin/master # Move master back to the latest commit common to the remote +git checkout newbranch # Go to the new branch that still has the desired commits +``` + ### Step 2: Local edition and commits In this phase, you can edit your files as you would normally do.