Git basic commands commands list
I am sumit kohli, consultant at SkillCone where we upskill engineers in FullStack, React, Javascript & Node . We follow unique approach with project based handson training to make them job ready. !
Now lets come to basic commands we will need on a daily basis!
git clone <repository link> → To clone a repo from remote to local
git add <file1, file 2, file 3> → Add a file to staging area.You can add multiple files. what is staging area? where files are added and kept just before commit.
git commit -m “<commit-message>” → commits the file. once comitted git remembers the commit and keeps it as a log.you can then run command git log to see all log
Get Sumit Kohli’s stories in your inbox
Join Medium for free to get updates from this writer.
To add all files inside a folder →git add foldername/*
To remove files from staging area → staging area is the area where all files are kept after adding and before comitting. the command is:
git restore — staged <filename1> <filename2>.
To remove all files from staging area run the command “git reset”.
if you have made any change in the file that is tracked by git. means file was committed at some time. and now you want to revert it back to previous commit. you can use the command:
git checkout <filename1><filename2>…
if you want to change all files in a particular folder back to the commit then you can do git checkout <folder>/*. the only condition is that folder should not contain any newly added file.
if you want to add only files of particular extension say .html only, then you have to do
git add *.html
git branch shows all active branches which you are using.
git branch -a shows all branches present in the local repository.
to delete branch use git branch -d . make sure u r not in that branch while deleting.
To delete a file, use git rm <filename> .
then do a commit and push. the file is deleted.
Class Assignment:
1) create src folder. add 4 files inside src folder.
2) add all files to staging using git add src/*
3)remove 2 files from staging area.
4) use git reset to remove all files from staging area with one command.




