Home > Blockchain >  Show a list of the latest commits in my current branch
Show a list of the latest commits in my current branch

Time:10-21

Is there a way to get a list of all commits after the commit I am checked out currently? For example in this image, I'm on commit 84a90... Commit History in Sourcetree

and in my terminal, I want to see a list of the next 3 commits, preferably with the commit comment & the changed files.

CodePudding user response:

git log --name-status is one option. Is there anything specific that is missing from the output of this command that you want to see?

CodePudding user response:

You can view the list of commits in formatted form --

git log --pretty=format:"%h -%an, %ai : %s"

CodePudding user response:

You can see the last 3 commits using the below commands

git show -3

CodePudding user response:

This should suffice

git log --oneline --name-status @..80200a0

CodePudding user response:

Git can only walk from any commit specified to older commits. To see commits younger than some other commit, you have to specify other commits, too, from which Git can walk backwards. For example:

git log --name-status --all ^HEAD   # or --not HEAD

CodePudding user response:

Your question is a bit tricky other people misunderstood. But I know what you are looking for. Lets say you checkout on a previous commit and you want see latest commits ahead of the previous commit.

 git log --branches --oneline ...

This will only show all the commits ahead of head.

Expected Output:

b452743 (tag: v0.1.2-beta, origin/master, origin/HEAD, master) update: close driver at the end
a150370 fix: remove spaces from header line
cb7d6f5 (tag: v0.1.1-beta) chore: remove folder from gitignore
968db4f add: example directory file
ab65070 (tag: v0.1.0-beta) Update README.md
ddfa102 Update README.md
20a3308 Update README.md
7500552 Update requirements

This will only show commits done after HEAD commit.

If you want to view including old commits:

git log --branches --oneline

Expected Output:

b452743 (tag: v0.1.2-beta, origin/master, origin/HEAD, master) update: close driver at the end
a150370 fix: remove spaces from header line
cb7d6f5 (tag: v0.1.1-beta) chore: remove folder from gitignore
968db4f add: example directory file
ab65070 (tag: v0.1.0-beta) Update README.md
ddfa102 Update README.md
20a3308 Update README.md
7500552 Update requirements
44220ff Fix argument passing in Listerner
05e7697 Fix remove unused config
726bea0 (HEAD) Fix #1
9ad4e4c Add webdriver, no longer need to download chromedriver
03bfc94 Update README.md
82cb75f Update README.md
b0d10d0 Update README.md
54f55c4 Create README.md
3f57df5 add requirements
88d5276 add README
eb29696 update gitignore
56a06ad update key listerner
df2398e update main.py
35fb259 update .gitignore
0e615f3 add utils
142314c add utils
6a548b7 add config
378ff5e add .gitignore
12c372d add placeholder main.py
  •  Tags:  
  • git
  • Related