Latest Updates

Post Top Ad

19 August, 2021

How to Add, Commit | Check Status & Log of file in Git

Steps to Add, Commit a file, and check Status & Log in Git


Follow the steps to create a file and add it to the staging area and commit to the local repo.




  • Open Linux Machine
  • Create a text file using vi editor
  • Status of the file in Writing Directory
  • Add file to Staging Area
  • Commit the file to Local Repo
  • Check git log


1. OpenLinux Machine on AWS Cloud

    Click Here for detailed steps: AWS Elastic Cloud Computing (EC2)

2. Create a text file using vi editor


3. Check the status of the file in the Writing Directory repository

      At this moment the file would be present in the Writing Directory and as Untracked File.

       git status



4. Add the file to the Staging Area of the Local repository

All untracked files are ready to be moved to the Staging Area of the local repository of git.
      
        git add .


Once we add the files to the git staging area the status of the untracked file changed to "Changes to be committed"

5. Commit the file to the Git Local repository


    git commit -m "First Code Committed" 
    
Here -m used to add a print/add a message along with commit.




Once we commit the file status will show "nothing to commit, working tree clean". At this moment there is no file present in the staging area to be committed. All files present in the staging area are now committed to the local git repository.

6. Check git log


    git log

    

    
    git log shows the following information:

    a. commit id - commit c3bd60b28762e3ecb03927860934a21cc32f8aeb
    b. Branch details - (HEAD -> master)
    c. Author- prakash
    d. Email Id of Author- ooyepiyush@gmail.com
    e. Date of commit- Thu Aug 19 17:43:48 2021 +0000
    f. Message of commit- First Code Committed


No comments:

Post Top Ad

Your Ad Spot

Pages