DevOps Classroomnotes 16/Sep/2022

Rewriting History

  • Consider the following history
    Preview
  • For the third commit i.e. your latest commit the commit there is typo in commit message
    Preview
  • consider the following history
    Preview
  • To rewrite history we need to back by 2 commits and rewrite history git rebase -i HEAD~2. This is called as interactive rebase.
    Preview
    Preview
  • Lets change all the commit messages and add my i.e my commit 1
    Preview
  • combine 3 and 4 commits into one => squash
    Preview
  • Now lets try deleting the commit 3 & 4 which was squashed
  • Before delete
    Preview
  • Command git rebase -i HEAD~3
    Preview
    Preview
  • Impact of rewriting history when working with remote repositories
  • Ensure you do the rewriting history either with teams approval
  • Git maintains one more log which is referred as reflog
    Preview
  • Exercise:

    • Create a new local repostory
    • create 3 commits (commit 1, commit 2, commit 3)
    • note commit id of commit 2
    • do interactive rebase to delete commit 2
    • now check git log
    • Use reflog to recover the deleted commit
  • Ignoring some files and folders to be tracked:

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube