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




    Picture showing the list of commits done on the git repository


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


  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




    Picture showing the list of commits with the latest commit on the top


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


Picture showing the checkout command executed on the git repository




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


Picture showing the text file overriden by the previous commit




Git checkout 95a6eeca9b742ba406ca611eac6bf6a30e98b4ef



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

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250