Followers

Git reset Assignment

  1. Create an empty file called tmp.java file in your current git repo. 2. Commit it in the local repo. 3. Modify tmp.java file by adding s...

 

1. Create an empty file called tmp.java file in your current git repo.

2. Commit it in the local repo.

3. Modify tmp.java file by adding some content to it and commit again in your local repo.

4. Now delete the last commit and revert back the changes of tmp.java file.

5. Check tmp.java, it should be empty.

6. Again modify tmp.java file and commit the changes

7. Delete tmp.java file and its commits. 


Check Answers below

Ans1 

touch tmp.java


Ans 2

git add tmp.java

git commit -m "tmp.java file is added"


Ans 3

echo "adding some content " >> tmp.java

git add tmp.java

git commit -m "tmp.java file is modified"


Ans 4

git reset --hard HEAD~1


Ans 5

  Yes


Ans 6

echo "adding some content " >> tmp.java

git add tmp.java

git commit -m "tmp.java file is modified again"


Ans 7

git reset --hard HEAD~2


COMMENTS

BLOGGER: 10
  1. 126 ls
    127 touch tmp.java
    128 git status
    129 git add tmp.java
    130 git status
    131 git commit -m "adding tmp.java"
    132 git log --oneline
    133 vi tmp.java
    134 git status
    135 git add tmp.java
    136 git commit -m "some modifications to tmp.java"
    137 git log --oneline
    138 git reset HEAD~1
    139 cat tmp.java
    140 git status
    141 git add .
    142 git status
    143 git commit -m "some modifications to tmp.java"
    144 git log --oneline
    145 git reset --hard HEAD~1
    146 cat tmp.java
    147 vi tmp.java
    148 cat tmp.java
    149 git status
    150 git add .
    151 git commit -m "some new changes to tmp.java"
    152 git log --oneline
    153 git reset --hard HEAD~1
    154 ls
    155 git log --oneline
    156 history

    ReplyDelete
    Replies
    1. It should be HEAD~2

      153 git reset --hard HEAD~2

      Delete
  2. Irfan

    422 touch tmp.java
    423 ls
    424 git add tmp.java
    425 git commit -m "tmp.java is added"
    426 git log --oneline
    427 git reset --soft HEAD~1
    428 git status
    429 echo "add some content into tmp.java" tmp.java
    430 cat tmp.java
    431 cat /tmp.java
    432 git commit -m "addedsome content already"
    433 git log --oneline
    434 ls
    435 cat tmp.java
    436 vi tmp.java
    437 git reset --soft HEAD~1
    438 git status
    439 echo "new lines added in tmp.java" >> tmp.java
    440 cat tmp.java
    441 git commit -m "tmp.java has been added some lines into it"
    442 git status
    443 git add tmp.java
    444 git commit -m "new lines are added in tmp.java"
    445 git status
    446 git log --oneline
    447 git reset HEAD~1
    448 ls
    449 git status
    450 git log --oneline
    451 git reset HEAD~1
    452 git log --oneline
    453 git status
    454 cat tmp.java
    455 git commit -m "tmp.java is added with new lines"
    456 git add tmp.java
    457 git commit -m "tmp.java added with new lines"
    458 git log --oneline
    459 git reset --hard HEAD~1
    460 ls
    461 history

    ReplyDelete
    Replies
    1. 463 touch tmp.java
      464 git add tmp.java
      465 git commit -m "tmp.java is added"
      466 echo "adding some content into tmp.java" >> tmp.java
      467 git status
      468 git add tmp.java
      469 git commit -m "tmp.java is modified"
      470 git log --oneline
      471 git reset --hard HEAD~1
      472 ls
      473 cat tmp.java
      474 echo "add some content again" >> tmp.java
      475 git add tmp.java
      476 git commit -m "tmp.java is modified again"
      477 git log --oneline
      478 git reset --hard HEAD~2
      479 git log --oneline
      480 ls
      481 history

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Asyraf

    109 touch tmp.java
    110 git add tmp.java
    111 git status
    112 git commit -m "tmp.java is added"
    113 git log --oneline
    114 git reset HEAD~1
    115 git log --oneline
    116 git status
    117 vi tmp.java
    118 git commit -m "File is being modified"
    119 git status
    120 git commit -m "File is being modified"
    121 git add tmp.java
    122 git status
    123 git commit -m "File is being modified"
    124 git log --oneline
    125 git reset --hard HEAD ~2
    126 git log oneline--
    127 git log --oneline
    128 history

    ReplyDelete
  5. Jerome

    662 touch tmp.java
    663 git add .
    664 git commit -m "tmp.java is added"
    665 git log --oneline
    666 echo "CHANGES 123" > tmp.java
    667 cat tmp.java
    668 git status
    669 git add .
    670 git commit -m "tmp.java has been modified"
    671 git log --oneline
    672 git reset --hard HEAD1
    673 git reset --hard HEAD~1
    674 cat tmp.java
    675 echo "CONTENT 345" > tmp.java
    676 git add .
    677 git commit -m "tmp.java has been modified again"
    678 git log --oneline
    679 git reset --hard HEAD~2
    680 git log --oneline
    681 ls

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. 98 clear

    99 git log

    100 initial commit

    101 git status

    102 git add tmp.java

    103 git commit -m "git tmp.java is added again"

    104 git log

    105 gi reset --soft

    106 git reset --soft

    107 git log

    108 git reset --soft HEAD~1

    109 git status

    110 git add tmp.java

    111 git commit -m "tmp.java added 3rd time"

    112 git log

    113 git reset --hard

    114 git reset --hard HEAD~1

    115 git log --oneline

    116 git status

    117 ls

    118 touch tmp.java

    119 echo "wassup homies" >> tmp.java

    120 vi tmp.java

    121 git add tmp.java

    122 git commit -m "tmp.java was added

    git commit -m "tmp.java was added"

    git log



    git status

    git add tmp.java

    "

    123 git log

    124 git commit -m "tmp file was added"

    125 git log

    126 echo "wassup wassup 2X" >>tmp.java

    127 vi tmp.java

    128 git add tmp.java

    129 git commit -m "tmp updated was added"

    130 git log

    131 git status

    132 git reset --soft HEAD~1

    133 vi tmp.java

    134 git reset --mixed HEAD~1

    135 vi tmp.java

    136 git log

    137 git status

    138 vi tmp.java

    139 echo "ok hope this works" >>tmp.java

    140 git commit -m "3rd one"

    141 git add tmp.java

    142 git commit -m "git added tmp.java 3rd"

    143 git status

    144 git log

    145 git reset --mixed HEAD~1

    146 git log

    147 git status

    148 vi tmp.java

    149 git reset --hard HEAD~1

    150 ls

    151 git log

    152 git status

    153 vi tmp.java

    154 git add tmp.java

    155 git log

    156 git status

    157 git commit -m "added tmp.java"

    158 git status

    159 git log

    160 vi tmp.java

    161 git reset --hard HEAD~1

    162 ls

    163 git log

    164 git status

    165 ls

    166 touch tmp.java

    167 git add tmp.java

    168 git commit -m "tmp is added now"

    169 echo "adding some content" >>tmp.java

    170 git add tmp.java

    171 git commit -m "tmp.java is modified"

    172 vi tmp.java

    173 git reset --hard HEAD~1

    174 ls

    175 vi tmp.java

    176 history

    ReplyDelete
  8. 580 touch tmp.java
    581 git add tmp.java
    582 git commit -m "tmp.java file is added"
    583 echo "adding some content " >> tmp.java
    584 git add tmp.java
    585 git commit -m "tmp.java file is modified"
    586 git reset --hard HEAD~1
    587 cat tmp.java
    588 echo "adding some content " >> tmp.java
    589 git add tmp.java
    590 git commit -m "tmp.java file is modified again"
    591 git reset --hard HEAD~2
    592 history

    pong

    ReplyDelete

Name

Ansible,6,AWS,1,Azure DevOps,1,Containerization with docker,2,DevOps,2,Docker Quiz,1,Docker Swarm,1,DockerCompose,1,ELK,2,git,2,git quiz,1,Git Worksheet,1,ITIL,1,ITSM,1,Jira,3,Kubernetes,1,Kubernetes Quiz,5,SAST DAST Security Testing,1,SDLC Quiz,5,SonarQube,3,Splunk,2,vagrant kubernetes,1,Windows,1,YAML Basics,1,
ltr
item
DevOpsWorld: Git reset Assignment
Git reset Assignment
DevOpsWorld
https://www.devopsworld.co.in/2022/02/git-reset-assignment.html
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/
https://www.devopsworld.co.in/2022/02/git-reset-assignment.html
true
5997357714110665304
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content