Git Essential Commands
Common Terminology & Flow:-
[untracked] → [unstaged] → [staged] → [commit]
Initial Configuration:-
Setting Name & Email Id:
Checking Name & Email Id:
Edit config file:-
Enable Git in a Directory:-
Adding File to Stage or to be Committed:-
Adding single unstage file to Stage:-
Adding all untracked files at once to Stage:-
Checking Git Status & Logs:-
Checking difference between last unstaged files with current unstaged files:-
Checking difference between staged files with last commit:-
Committing Staged Files:-
Commit via Nano/Vi Editor:-
Commit without Nano/Vi Editor:-
or
Stage & Commit all files at once:-
Git checkout & restore command:-
Matching current files & Staged with last commit:-
Travel back to any last commit (HEAD pointer only, it will detach HEAD pointer):-
Reverting staged file back to unstaged:-
Removing / Deleting files :-
Git Ignore:-
Git Branches:-
Creating git branch:-
Checking branch status:-
Switching from master branch to custom branch:-
Switching from custom branch to master branch:-
Merging custom branch with master branch:-
Creating & Switching from master to custom branch:-
Cancel / Exit merge process when conflicts occurs:-
Deleting git branch:-
Git Remote:-
Setting SSH keys with GitHub Account:-
check all remote names:-
rename remote alias:-
remove remote url from an alias:-
remove a alias:-
pushing local git changes & files to remote github account:-
pulling remote git changes & files to local git:-
or
Open source contribution:-
Git revert command (undo):-
edit last commits message:-
reverts all of the changes back to a specific commit:-
Git clean command:-
Dry run:-
To delete untracked files forcefully:-
To delete untracked directories forcefully:-
Git reflog command:-
Check all commit history (even done after git reset --hard) :-
Check all HEAD pointer history:-
Git update-index command:-
Tell git you want to start ignoring the changes to the file:-
When you want to start keeping track again:-
To check untracked / tracked file status:-
Git ls-files command:-
Git reset command (dangerous):-
Revert your git to any last commit, it will revert back to log_id & remove all commit logs after log_id you given (but you can see that all commits using reflog command) :-
Git stash command:-
Put your changes to stash:-
Get your stashed things back to your working tree & delete from stash:-
Show stash details:-
List all stashed items:-
Get specific stashed item back:-
Remove specific stashed item:-
Clean or Empty your stash:-
To apply stashed change:-
Creates a new branch with the latest stash, and then deletes the latest stash ( like stash pop):-
References:-
Git reset vs revert command:-
https://www.pixelstech.net/article/1549115148-git-reset-vs-git-revert
Open source contribution:-
https://www.dataschool.io/how-to-contribute-on-github/
How to manage multiple GitHub accounts on a single machine with SSH keys:-
https://www.freecodecamp.org/news/manage-multiple-github-accounts-the-ssh-way-2dadc30ccaca/
Git error - Fatal: Refusing to merge unrelated histories and how to fix it:-
https://www.datree.io/resources/git-error-fatal-refusing-to-merge-unrelated-histories
Git error - push rejected:-
https://stackoverflow.com/questions/620253/git-push-rejected
https://footle.org/2013/06/26/why-is-git-rejecting-me/#:~:text=If your push is rejected,rebase
Last updated
Was this helpful?