lab 30 Resetting the Main Branch
Goals
- Reset the main branch to the point before the conflicting commit.
Reset the main branch
When we added the interactive mode to the main branch, we made a change that conflicted with changes in the greet branch. Let’s rewind the main branch to a point before the conflicting change. This allows us to demonstrate the rebase command without worrying about conflicts.
Execute:
git checkout main git hist
Output:
$ git hist * b74b20e 2023-08-21 | Made interactive (HEAD -> main) [Théophile Chevalier] * 6179ba3 2023-08-21 | Added README [Théophile Chevalier] * 9ab61ca 2023-08-21 | Moved hello.py to lib [Théophile Chevalier] * 7abea37 2023-08-21 | Add an author/email comment [Théophile Chevalier] * 1c410c6 2023-08-21 | Add a comment (tag: v1) [Théophile Chevalier] * 0bf384c 2023-08-21 | Display user input (tag: v1-beta) [Théophile Chevalier] * 31c3945 2023-08-21 | Add some content [Théophile Chevalier] * aa5d425 2023-08-21 | First Commit [Théophile Chevalier]
The ‘Added README’ commit is the one directly before the conflicting interactive mode. We will reset the main branch to ‘Added README’ commit.
Execute:
git reset --hard <hash> git hist --all
Review the log. It should look like the repository has been wound back in time to the point before we merged anything.
Output:
$ git hist --all * 6179ba3 2023-08-21 | Added README (HEAD -> main) [Théophile Chevalier] | * cc98109 2023-08-21 | Hello uses Greeter (greet) [Théophile Chevalier] | * d6aae18 2023-08-21 | Add greeter class [Théophile Chevalier] |/ * 9ab61ca 2023-08-21 | Moved hello.py to lib [Théophile Chevalier] * 7abea37 2023-08-21 | Add an author/email comment [Théophile Chevalier] * 1c410c6 2023-08-21 | Add a comment (tag: v1) [Théophile Chevalier] * 0bf384c 2023-08-21 | Display user input (tag: v1-beta) [Théophile Chevalier] * 31c3945 2023-08-21 | Add some content [Théophile Chevalier] * aa5d425 2023-08-21 | First Commit [Théophile Chevalier]