Here are some of the top
git commands that I handpicked, which can be useful for increasing your productivity and saving you time.
If you want to update the message of your last commit because it didn't look conventional or meaningful, use this command to edit it:
git commit --amend -m "Updated message"
Sometimes we need a blank commit (no changes added or deleted), maybe to initialize our repository or trigger some kind of action. We can use this command:
git commit --allow-empty -m "blank commit message"
If you want to check the total number of commits on a particular branch, you can use this command:
git rev-list --count <branch-name>
git rev-list --count main
If you want to view some files from a different branch while working on a different branch, you can use this command:
git show <branch-name>:<file-name>
For example, if you are working on the
test branch and want to see the README.md file from the
main branch, you can use this command:
git show main:README.md
Instead of doing
git add and
git commit separately, you can use this single command to perform both actions:
git commit -am "message"
Yes! You heard it right. With only a single command, you can have a whole git tutorial at your fingertips.
git help tutorial