What is Git?

Git is a version control system for easy management of files. In other words, it is used for managing a set of files that are often updated. Some examples of these set of files could be manuscripts edited by multiple authors, research source codes or a publically available list of scholarships maintained by student community. Git stores and maintains the each version of each of the files efficiently, thus relieving this burden off the authors. It is mainly used by programmers for maintaining different versions of the codes as they fix the bugs.

Initial Setup

> git init
Initializing empty Git Repository in PWD

The command given above initializes git in the present working directory (PWD). You’ll see one hidden folder ~.git~ being created in the PWD. This folder is responsible for version control of files and directories within this folder, therefore, it is important to not make any modification in them.

Funfact: Git only stores the differences and not the complete files, thus making it memory efficient

If you want to view all the files and folders in your PWD, use the following command:

> ls
webscrape.py  results.csv  new_modifications.md

We want to track these files using git, so we can add them to the repository by the following command.

> git add .

To check which files are being added, use the status command.

> git status
# On branch master
#
# Initial commit
#
# Changes to be committed :
# (use "git rm −−cached <file> . . . " to unstage)
#
# new file : webscrape.py
# new file : results.csv
# new file : new_modifications.md
#

Now, we need to ‘commit’ these files to make sure that the changes are saved.

> git commit .

This opens up vim editor in the form given below to write a long for our commit. In this case, we just write a log message of Adding new files and :wq the editor

Adding new f i l e s

Adding new files
# Please enter the commit message for your c h ange s . Lines starting
# with ’#’ will be ignored, and an empty message aborts the commit .
# Explicit paths specified without −i nor −o ; assum ing −−only paths...
#
# Committer : burhan sabuwala <[email protected]>
#
# On branch master
#
# Initial commit
#
# Changes to be committed :
# ( use "git rm −−cached <file> ... "to unstage)
#
# new file : webscrape.py
# new file : results.csv
# new file : new_modifications.md
#

Upon committing the files, the following messages are displayed.

[master (root−commit) ea43c43] Adding new files
2 files changed, 23 insertions(+) , 0 deletions()
create mode 100644 webscrape.py
create mode 100644 results.csv
create mode 100644 new_modifications

Now, a git status will tell you that no changes to commit, i.e. we just committed our files to git repository and did not modify the files after our last commit (as shown below):

> git status
# On branch master
nothing to commit (working directory clean)

References and resources for further use

  1. https://git-scm.com/doc
  2. https://www.atlassian.com/git \\\