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 filegit 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âŚ