As part of summer training at #dgplug, Sayan took our basics to Git session. We were introduced to basics of VCS(Version Control System), need to use a VCS and introduction to Git.

These were some of commands we learn during the session conducted over the course of two days,

  • git init is used initialize Git repository

    1
    
    $ git init
  • git config to used to configure various Git configuration using below command one can configure their Name and Email globally for Git.

    1
    2
    
    $ git config --global user.name "<Name>"
    $ git config --global user.email "<email>"
  • git add is used to add files to stage area in Git.

    1
    2
    3
    
    $ git add helloworld.txt
    $ git add .
    $ git add -u
  • git status to see status of you Git repoistory. Whether there are changes that are still not added to stage or there are changes which are added to stage but not committed.

    1
    
    $ git status
  • git commit is used to commit your files from stage.

    1
    
    $ git commit -m "Snapshot 2"
  • git diff is used to difference betwen current state and previous state.

    1
    
    $ git diff
  • git log is used to get commit logs.

    1
    2
    3
    4
    
    $ git log
    $ git log -2
    $ git log -p -2
    $ git log --stat

As part of home task we were asked to read https://chris.beams.io/posts/git-commit/, which explains How to write a Git commit message.

The seven rules of a great Git commit message are:

  • Separate subject from body with a blank line
  • Limit the subject line to 50 characters
  • Capitalize the subject line
  • Do not end the subject line with a period
  • Use the imperative mood in the subject line
  • Wrap the body at 72 characters
  • Use the body to explain what and why vs. how