Last active
June 1, 2020 05:56
-
-
Save SirLordPouya/ae6135dec55e7848331ff03e0acca67c to your computer and use it in GitHub Desktop.
Git terminal commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here is a list of commands and their flags that helps you while using Git: | |
----------- | |
To clone a project from the repository: | |
git clone [url] | |
git clone [url] [folderName] | |
----------- | |
To see what is added to the staging area or what is changed but not added: | |
git status | |
----------- | |
To see past commits with details (Author, Date, Message): | |
git log | |
----------- | |
to see past commits with only the message: | |
git log --oneline | |
----------- | |
To see past commits with details (Author, Date, Message, Files that changed): | |
git log --stat | |
----------- | |
To see a graph in terminal beside commit history: | |
git log --graph | |
----------- | |
To see log for all branches: | |
git log --all | |
----------- | |
To see past commits with details (Author, Date, Message, Files that changed, The changes): | |
git log -p | |
git log -p [SHA of a commit] | |
git log -p -w (no white spaces) | |
----------- | |
Easy keyword for "git log -p" for just the last commit: | |
git show | |
git show [SHA] | |
----------- | |
To see changes that are not commited yet: | |
git diff | |
----------- | |
To set a tag for the last commit: | |
git tag -a tagName | |
----------- | |
To see tags: | |
git tag | |
----------- | |
To delete a tag: | |
git tag -d tagName | |
----------- | |
To set a tag for a commit: | |
git tag -a tagName SHA | |
----------- | |
To create a branch: | |
git branch branchName | |
git branch branchName [SHA] | |
----------- | |
To delete a branch: | |
git branch -d branchName | |
----------- | |
To create a branch and checkout to it: | |
git checkout -b branchName | |
----------- | |
To merge 2 branches: | |
git merge branchName | |
----------- | |
To edit last commit message or add files to it: | |
git commit --amend | |
----------- | |
To undo changes that happened in a commit: | |
git revert SHA | |
----------- | |
To see deleted commits: | |
git reflog | |
----------- | |
To delete a commit: | |
git reset --hard HEAD^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment