This content originally appeared on DEV Community and was authored by Pradumna Saraf
Here are some of the top git
commands which I handpicked, that can be useful to increase your productivity, and also save your some time.
1) Updating the last commit message.
If you want to update the message of your last commit, because either it didn't look conventional or meaningful, use this command to edit it:
git commit --amend -m "Updated message"
2) Blank Commit.
Sometimes we need a blank commit (no changes added or deleted) maybe we need to initialize our repo or trigger some kind of action, we can use this command:
git commit --allow-empty -m "blank commit message"
3) Checking the total number of commits.
If we want to check the total no of the commit on a particular branch we can use this command.
git rev-list --count <branch-name>
Eg:
git rev-list --count main
4) Checking files from different a branch.
If we want to view some files from a different branch while working on a different branch, we can use this command:
git show <branch-name>:<file-name>
For Eg: If we are working on the test
branch and want to see the README.md file of the main
branch, we can use this command:
git show main:README.md
5) Stagging (adding) and committing the changes in a single command.
Instead of doing git add
and git commit
separately, we can use this single command to perform this:
git commit -am "message"
6) Git tutorial on the terminal.
Yes!,you heard is right, with only single command use can have a whole git tutorial at your fingertips.
git help tutorial
For Support and Reachout: Twitter LinkedIn
This content originally appeared on DEV Community and was authored by Pradumna Saraf
Pradumna Saraf | Sciencx (2022-01-30T13:48:22+00:00) 6 git commands, you may not know.. Retrieved from https://www.scien.cx/2022/01/30/6-git-commands-you-may-not-know/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.