Git has many commands but you can be productive with just a few. I used the script below to fetch my most git commands sorted by the number of their occurrences:
You can copy the script here:
history | awk '{print $2 $3}' | grep '^git' | sort | uniq -c | sort -nr | head -10
I’ve limited the list to just 10 commands but some of these can be extended with command options and arguments which make their uses different and making them somewhat versatile.
$ git status
2.1. Add files
$ git add [file1] [file2]
2.2. Add all
$ git add .
2.3. Add specific changes
$ git add -p [file]
3.1. With a message
$ git commit -m "[message]"
$ git commit -m "add login button"
3.2. Without a message
$ git commit
3.3. Modify commits
$ git commit --amend
4.1. Basic usage
$ git branch
4.2. Create a branch
$ git branch [branch-name]
$ git branch feature/login-button
4.3. Delete a branch
$ git branch -d [branch-name]
4.4. Rename a branch
$ git branch -m [old-name] [new-name]
5.1. Basic usage
$ git push
5.2. Upstream a branch
$ git push -u [remote] [local-branch]
$ git push -u origin feature/login-button
5.3. Rename an upstream branch
$ git push -u [remote] [local-branch]:[remote-branch-rename]
$ git push -u origin feature/login-button:WIP/feature/login-button
6.1. Basic usage
$ git checkout [branch]
6.2. Create a branch
$ git checkout -b [new-branch]
6.3. Select commit
$ git checkout [commit-sha]
6.4. Undo changes
$ git checkout [file1] [file2]
6.5. Undo all changes
$ git checkout .
7.1. Basic usage
$ git log
7.2. Short version
$ git log --oneline
7.3. Search commit changes
$ git log -S"[code]"
$ git log -S"<button>Login</button>"
8.1. Basic usage
$ git pull
8.2. Specific branch
$ git pull [remote] [remote-branch]
$ git pull origin feature/login-button
9.1. Basic usage
$ git diff
9.2. Specific file
$ git diff [file]
9.3. See staged files
$ git diff --staged
10.1. Unstage files
$ git reset [file1] [file2]
10.2. Unstage all
$ git reset .
10.3. Undo commits
$ git reset [commit-sha]
Originally published at https://micogongob.com/how-to-see-your-most-used-git-commands