Skip to main content

Git: Version Control for your Code

What is git

Git is a version control system that is used to track changes in sour source code during development. To install git go here

Basic Git Commands

git init

Run the following command in the folder or location that you would like to be a git repository.

This command will create an empty git repository in the folder.

git add

This command updates your git repository with any new or modified files to a staged state which is in preparation to commit these changes to your git history.

This command can be called in several ways:

This will add all changes in the current folder to a staged state.

Use this command to add specific files to the staging state

git commit

Commiting is saving any changes that are currently in the staged state to your git history. You will be able to view or return to any commit to see your source code at that particular version.

The committing command is:

The option -m allows you to add a message to the current version of the code you are saving. If you do not add the -m your terminal will open up a text editor for you to add the commit message.

git status

This command will show you the state of your current git repository, it will show you any files which are currently in the staged state and have not yet been committed. It will also show you any files that are currently not being tracked by git.

Version control is very important in order to keep track of changes and revert to a previous state of the source code.

Leave a Reply

Your email address will not be published. Required fields are marked *

Select your currency