Skip to content
Snippets Groups Projects
Commit f5f6e266 authored by Francisco-Javier Ramon Salguero's avatar Francisco-Javier Ramon Salguero
Browse files

Procedure to move commits in master to a branch

parent 65a5499d
No related branches found
No related tags found
No related merge requests found
......@@ -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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment