First steps with Git Version Control

The following guide covers the basics of Git: installing Git on your system, initializing repository, commiting files, adding remote, and collaborating on branches with other users. This is some pretty straightforward stuff, good to keep at hand until Git becomes your lifelong friend for good and bad.

A NOTE BEFORE YOU GET STARTED The best way to understand how Git works is to run Git commands from your terminal. If you’re a Windows user make sure to run git bash when adding your Git package.


First you need to choose and install the package for your OS:

Creating repository

Once the Git is installed, go to the folder with your project and run

git init

to initialize Git in this directory. This command will add a /.git directory to your folder that will store data about the repo.

Adding files to the repository

Now we need to tell Git to put the files under version control so we can commit them. To do this, run:

git add .

With ‘git add’ you can define which files you want to add to the next commit:

  • git add filename will add a specific file
  • git add . will add all files from the directory.

Once the files have been added, you can commit them to the repository:

git commit -m ‘Added all files to the repository’

where -m stands for the commit message. Always write something that describes your activity in the commit to avoid mess when browsing the history later on.

To view which files have been added and/or modified, use…

More by Buddy

Topics of interest

More Related Stories