Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the latest commits in one git repository?

Tags:

git

github

I have one git repository, there are many branches many commits, I want to find the latest 10 commits, how to do this , thanks!

like image 527
why Avatar asked Mar 13 '12 05:03

why


People also ask

How do I check the latest commit?

To pull up a list of your commits and their associated hashes, you can run the git log command. To checkout a previous commit, you will use the Git checkout command followed by the commit hash you retrieved from your Git log.

How do I see my git history?

Git file History provides information about the commit history associated with a file. To use it: Go to your project's Repository > Files. In the upper right corner, select History.

How can I see how many commits in a git repository?

Use the following command to find out how many commits there have been in a git repository. Not really useful in itself, but an interesting figure to see how active a project has been over it's lifetime. --oneline - Removes some of the information from the log entries and displays each on a single line.

How to show only the most recent commit in git log?

git log my/file.c If you really only want to list the one most recent commit, for example to use it in a script, use the -n 1 option: git log -n 1 --pretty=format:%H -- my/file.c --pretty=format:%h tells git log to show only the commit hash.

How to get all commits for all branches in Git?

If you want commits for all branches you need the --all argument, limit git log to ten with -10 and use --date-order to tell git log to sort the commits with respect to date. git log -10 --all --date-order

How do I view the commit history of the repository?

The commit history can be viewed in different ways by using the ` git log ` command. A local repository named bash has been used in this tutorial to test the commands used in this tutorial. Run the following command to view the commit history of the repository.


4 Answers

If you want commits for all branches you need the --all argument, limit git log to ten with -10 and use --date-order to tell git log to sort the commits with respect to date.

git log -10 --all --date-order
like image 138
ralphtheninja Avatar answered Oct 03 '22 03:10

ralphtheninja


For last 10 commits in all branches, you can do:

git log --graph --all --format=format:'%h - (%ai) %s — %cn %d' --abbrev-commit --date=relative -10
  • %h is the commit hash
  • %ai is author date (use %ci for committer date)
  • %s is the commit subject
  • %cn is the committer name
  • -10 means last 10 commits

See here for more info if you need to customize further: http://linux.die.net/man/1/git-log

like image 45
triad Avatar answered Oct 03 '22 04:10

triad


To find specific number of commits you can use the -n option :

git log -5  # or git log -n 5 # fetches the last 5 commits

As, @honk pointed out, -n 5 and -5 are equivalent.

To find commits on other branch, without checking out the other branch :

git log branch_name

So, if you are at develop branch and wish to get last 10 commits of master(oneline), you could do:

git log --oneline master  -10

To view commits of all branches there's a --all argument.

git log --all
like image 37
prasvin Avatar answered Oct 03 '22 04:10

prasvin


Try this git log --graph & you will get the commits in the order latest to old along with

•the checksum of the commit 
•the author name and email 
•the date the author committed it 
•the full commit message

EDIT:

or you can use:

git log --pretty=oneline --graph

which gives all the commits & branch topology

like image 36
uday Avatar answered Oct 03 '22 04:10

uday