Articles → GIT → Checkout Operation In GIT

Checkout Operation In GIT






What Does Checkout Mean?





Example




  1. Create an empty text file ‘1.txt’.
  2. Add ‘1.txt’ in git repository using the following command
  3. Git  add 1.txt
    Git commit  1.txt -m “Committing 1.txt”


    Picture showing the commit operation in git
    Click to Enlarge



    Picture showing the list of commits done on the git repository
    Click to Enlarge

  4. Modify “1.txt” and add following text
  5. Picture showing the text file in which text is modified
    Click to Enlarge

  6. Commit the changes using the commit command
  7. Git commit 1.txt -m “Commit 1.txt 2nd time”


    Picture showing the changes committed in the git repository for 1.txt file
    Click to Enlarge



    Picture showing the list of commits with the latest commit on the top
    Click to Enlarge

  8. If we want to switch to previous commit then we can use checkout command
  9. Git checkout f25908abe8eec7fa4e417573e0d603217b392a78


Picture showing the checkout command executed on the git repository
Click to Enlarge



Picture showing the list of commits with the head pointer pointed to the previous commit
Click to Enlarge

Picture showing the text file overriden by the previous commit
Click to Enlarge



Git checkout 95a6eeca9b742ba406ca611eac6bf6a30e98b4ef



Posted By  -  Karan Gupta
 
Posted On  -  Thursday, June 27, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250