Basic Git Commands
Tips | June 01, 2018
This is a basic list of frequently used (by me) Git commands.
- Tracked - any file already in the repository or staged in the index.
- Ignored - any file that is declared invisible or ignored in the repository though present in the working directory.
- Untracked - any file that is neither tracked nor ignored.
Git command list
|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 commit –message||Same as git commit -m.|
|git commit –all||Stages all known modified files and commits them.|
|git log||View comments.|
|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.|