DevOps Classroomnotes 16/Sep/2022

Rewriting History

  • Consider the following history
  • For the third commit i.e. your latest commit the commit there is typo in commit message
  • consider the following history
  • To rewrite history we need to back by 2 commits and rewrite history git rebase -i HEAD~2. This is called as interactive rebase.

  • Lets change all the commit messages and add my i.e my commit 1
  • combine 3 and 4 commits into one => squash
  • Now lets try deleting the commit 3 & 4 which was squashed
  • Before delete
  • Command git rebase -i HEAD~3

  • 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
  • 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 ReplyCancel reply

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

Please turn AdBlock off
Customized Social Media Icons from Acurax Digital Marketing Agency

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Exit mobile version
%%footer%%