🚀 DevOps & SRE Certification Program 📅 Starting: 1st of Every Month 🤝 +91 8409492687 🔍 Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

Git Lab Exercise & Assignment: Changing History with Amend: Part – 5


code>
# 1. Add line4 with a typo, commit
$ echo "line44" >> new.txt
$ git commit -a -m "Added new.txt line4."
# 2. Note our history
$ git l
# sha-a "Added new.txt line4."
# 3. Fix our typo, amend the commit
$ sed -i s/line44/line4/ new.txt
$ git commit -a --amend
# 4. Note history, there is one, different "line4" commit
$ git l
# sha-a' "Added new.txt line4."
# commit sha = hash(timestamp, author, message, repo contents)
# amending always changing the last commit's sha
# 5. Change new, new-b in separate commits
$ echo "line5" >> new.txt
$ git commit -a -m "Added new line5."
$ echo "line3" >> new-b.txt
$ git commit -a -m "Added new-b line3."
# 6. Rebase to re-order the commits
$ git rebase -i HEAD~2
# oldest is listed first
# pick sha-a "Added new line5."
# pick sha-b "Added new-b line3."
# Change order of lines:
# pick sha-b "Added new-b line3."
# pick sha-a "Added new line5."
# Save/quit
# 7. Note history
$ git l
# 8. We screwed up, pretend line3/line5 never happened
$ git reflog
# Shows what "HEAD" was X commits ago
# Find 'commit (amend): Added line4'
$ git reset --hard HEAD@{N}
$ cat new.txt # no line5
$ cat new-b.txt # new line3
Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x