🚀 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: Git Diff and Undoing: Part – 9


Excercise 1 - Module 1 - Simple Commit
# 0. Clone from github
$ git clone http://github.com/stephenh/git-workshop.git
$ cd git-workshop
# 1. Tell git who you are (once per machine)
$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com
$ git config --global color.ui auto
# 2. Make a new file
$ echo "line1" > new.txt
# 3. See your status, new.txt is untracked
$ git status
# 4. Stage the new file
$ git add new.txt
# 5. git status, new.txt is "to be committed"
$ git status
# Think of "svn commit file1 file2", in git this
# is "add file1", "add file2", "commit". Staging,
# then committing.
# 6. commit
$ git commit -m "Added new.txt."
# 7. See the history
$ git log
# 8. Add a nice alias for log (no newlines)
$ git config --global alias.l "log
--graph
--pretty=oneline
--abbrev-commit
--decorate"
$ git l
Excercise 1 - Module 2 - Diff, Undo Line Changes
# 1. Add a line to new.txt, see the status
$ echo "line2" >> new.txt
$ git status
# 2. See the change
$ git diff
# 3. Undo your change, line2 is removed, nothing to commit
$ git checkout new.txt
$ git status
# 4. Re-add line 2 and now stage the change
$ echo "line2" >> new.txt
$ git add new.txt
# 5. See the staged change
$ git diff --staged
# 6. Note regular diff does not show changes
$ git diff
# diff == working <-> staged
# diff --staged == staged <-> HEAD
# 7. Unstage the change, new.txt is back to modified
$ git reset new.txt
$ git status
# 8. Undo the change, line2 is removed, nothing to commit
$ git checkout new.txt
$ git status
Excercise 1 - Module 3 - Diff, Undo File Changes
code>
# 1. Add, stage a new file, see it staged
$ echo "line1" > new-b.txt
$ git add new-b.txt
$ git status
# 2. Unstage the new file, new-b.txt is back to untracked
$ git reset new-b.txt
$ git status
$ rm new-b.txt
# 3. Remove new.txt, it is shown as deleted
$ rm new.txt
$ git status
# 4. Stage the removal, it is shown as "to be committed"
$ git rm new.txt
$ git status
# 5. Unstage the removal (HEAD is important, try without it)
$ git reset HEAD new.txt
$ git status
# 6. Restore new.txt in working copy
$ git checkout new.txt
$ git status
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