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

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

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

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

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

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

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

    $ git log
    $ git log -2
    $ git log -p -2
    $ git log --stat

As part of home task we were asked to read, 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