GIT Commands

2 minutes read

Git Commands List


sudo apt install git – installs GIT from repositories;


git config –global “Your Name” – the name that will be added to commits and tags;
git config –global “” – the e-mail address that will be added to commits and tags;
git config –global color.ui auto – enables the colors in GIT output;


git init [project name] – creates a new local repository;
git clone [project url] – gets a project from remote repository;


git status – shows the status of your work;
git diff – shows the changes;
git checkout – discards changes in working directory;
git add – adds a file to staging area;
git reset [file] – gets file back from staging area;
git commit [-m “message”] – commits the changes added to staging area;
git rm [file] – removed the file from working directory and adds deletion to staging area;
git stash – puts changes into stash;
git stash pop – applies the changes in the stash and clears its contents;
git stash drop – clears the stash contents;


git branch [-a] – lists all branches in repository;
git branch [name] – creates a new branch;
git checkout [-b] [name] – changes working directory to the mentioned one;
git merge [from name] – Combines the specified branch with the current one;
git branch -d [name] – removes branch;


git tag – lists tags;
git tag [name] [commit *] – creates a tag for current commit;
git tag -a [name] [commit *] – creates a tag object for current commit;
git tag -d [name] – removes a tag from repository;


git log [-n count] – lists commit history;
git log –oneline –graph –decorate – shows references and history graph;
git log ref.. – shows commits that are present on current branch and not merged into ref;
git log ..ref – lists commits that are present on ref and not merged into current branch;
git reflog – list operations made on local repository;


git fetch [remote] – gets changes from the remote but does not update the branches;
git fetch –prune [remote] – removes refs from remote;
git pull [remote] – gets changes from the remote and combines current branch with it;
git push [–tags] [remote] – pushes local changes to remote;
git push -u [remote] [branch] – pushes local branch to remote repository;


git reset [–hard] [target reference] – switches current branch to the target reference;
git revert [commit *] – createa a new commit, reverting changes from the specified commit;


cat .gitignore
#Contents of .gitignore

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

GIT is a revision control system that allows multiple contributors to work on same projects/files. Is also useful if you have more servers/vms/workstation that you manage and you want to deploy “recipes”/scripts/configurations on them. With GIT, you work local...
Many Linux commands deal with sensitive data like system hardware, passwords or operate under exceptional circumstances. Prevents regular users from executing these commands by mistakes and helps to protect data and system integrity. By logging in as root enab...
Before you start this tutorial is better to know how to get help and details about the commands, when you need it. There are several ways to get help about the commands, but I will present only the most important ones: Using –help as argument for the command E...
Git refspecs specifies the patterns for references on the remote side and the locally tracked branch. When you create a new repository and add a new remote to it i.e git remote add origin url
Here is a list that contains one of the most used Linux commands, and a short explanation for them: ls – list – lists files and directories, can be used with a lot of options like: -a, -R, -l, -g, -r; pwd – print working directory – shows the path of the curre...
Git merge lets you bring the changes from one branch, on to the other. Merge replays the changes in a branch on top another, starting from the commit where the two branches last diverged. Lets take for instance 2 different branches.