Basic Git Commands

Published 01 June 2018 | Posted under TechTips

This is a basic list of frequently used (by me) Git commands.

File classifications

Git command list

Command Description
git Git Help.
git version Provides version of git.
git init Create a repository. Create a directory, such as /example. cd to this directory and run git init to turn the directory into a repository.
git add Staging a file. For example, run git add index.html to add this file to the new repository.
git status Check the state of the repository. Shows which files need to be committed.
git commit Commits a file to the remote repository.
git commit - m “A comment added to the commit” Commits and adds comment.
git Git Help.
git commit –message Same as git commit -m.
git commit –all Stages all known modified files and commits them.
git log View comments.
git Git Help.
git rm filename Removes file from both repository and working directory.
git commit - “Remove a file called filename” Same as git rm filename but adds a comment.
git clone repository_directory new_repository_directory Makes a copy (a clone) of a repository
git mv filename newfilename Moves a file to a new filename (same as renaming.
git commit -m “renamed filename to newfilename” Renames a file.