📅  最后修改于: 2023-12-03 14:41:26.449000             🧑  作者: Mango
As a programmer, you should be familiar with Git and its many commands. One of the most important commands is git log
, which allows you to view the commit history of a repository. This command can be especially useful when you want to view the commits that you have made to a repository. Here's how to use git log
to view your commits.
The basic git log
command will show the commit history of the current branch. To view your commits, you can add the --author
flag followed by your GitHub username like this:
git log --author=yourusername
This will show only the commit history that you have made.
There are several options that you can use with git log
to customize the output of the command. Here are some of the most useful options:
--pretty=format:""
: This option allows you to customize the output format of git log
. You can use placeholders to include information like the author, commit message, and commit hash in the output. Here is an example format string that shows the author, commit hash, and commit message:git log --pretty=format:"%h - %an, %s"
--oneline
: This option creates a compact output format that shows only the first line of each commit message.
--since
: This option allows you to show commits after a certain date. Use the format yyyy-mm-dd
to specify the date.
--until
: This option allows you to show commits before a certain date. Use the format yyyy-mm-dd
to specify the date.
git log
is a powerful command that allows you to view the commit history of a repository. By specifying the --author
option, you can easily view your own commits. There are also several options that you can use to customize the output of the command. With these options, you can quickly and easily access the information you need to manage your codebase.