lab 31 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 * 3c663d0 2019-06-27 | Made interactive (HEAD -> main) [Halle Bot] * 3aa3064 2019-06-27 | Added README [Halle Bot] * 2b04803 2019-06-27 | Added a package.json. [Halle Bot] * b65b430 2019-06-27 | Moved hello.js to lib [Halle Bot] * 4535421 2019-06-27 | Add an author/email comment [Halle Bot] * 59992ce 2019-06-27 | Added a comment (tag: v1) [Halle Bot] * 20a6c79 2019-06-27 | Added a default value (tag: v1-beta) [Halle Bot] * 6915d41 2019-06-27 | Using process.argv [Halle Bot] * 284070d 2019-06-27 | First Commit [Halle Bot]
The ‘Added README’ commit is the one directly before the conflicting interactive mode. We will reset the main branch to ‘Added README’ branch.
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 * 3aa3064 2019-06-27 | Added README (HEAD -> main) [Halle Bot] | * f52644d 2019-06-27 | Updated package (greet) [Halle Bot] | * 455c54f 2019-06-27 | Hello uses Greeter [Halle Bot] | * 4fb8bde 2019-06-27 | Added greeter class [Halle Bot] |/ * 2b04803 2019-06-27 | Added a package.json. [Halle Bot] * b65b430 2019-06-27 | Moved hello.js to lib [Halle Bot] * 4535421 2019-06-27 | Add an author/email comment [Halle Bot] * 59992ce 2019-06-27 | Added a comment (tag: v1) [Halle Bot] * 20a6c79 2019-06-27 | Added a default value (tag: v1-beta) [Halle Bot] * 6915d41 2019-06-27 | Using process.argv [Halle Bot] * 284070d 2019-06-27 | First Commit [Halle Bot]