paint-brush
First steps with Git Version Controlby@BuddyWorks
1,244 reads
1,244 reads

First steps with Git Version Control

by BuddyOctober 10th, 2016
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

The following guide covers the basics of <a href="https://hackernoon.com/tagged/git" target="_blank">Git</a>: 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.

Company Mentioned

Mention Thumbnail
featured image - First steps with Git Version Control
Buddy HackerNoon profile picture

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.

Installation

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…

Want to learn more? Check out the full article here.