Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to view git commits when local branch is ahead of origin Commits

I want to view git commits when my branch is ahead of origin branch.

i tried git log it returns all commits. but, i want to view only ahead commits from branch to origin/branch

here what i mean,

On branch permissions
Your branch is ahead of 'upstream/permissions' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working directory clean

in this case i want to view 2 commits

like image 285
Mohideen bin Mohammed Avatar asked Jun 30 '17 13:06

Mohideen bin Mohammed


People also ask

How can I see commits from one branch?

Git rev-list will list commits in one branch that are not in another branch. It is a great tool when you're trying to figure out if code has been merged into a branch or not. Using the --oneline option will display the title of each commit. The ^ operator excludes commits in the specified branch from the list.

How do I fix my branch is ahead of origin master by three commits?

There is nothing to fix. You simply have made 3 commits and haven't moved them to the remote branch yet. There are several options, depending on what you want to do: git push : move your changes to the remote (this might get rejected if there are already other changes on the remote)

What does your branch is ahead of origin Main by 1 commit?

The message you are seeing (your branch is ahead by one commit) means your native repository has one commit that hasn't been pushed yet. In other words: add and commit are local operations, push, pull and fetch are operations that interact with a remote.


1 Answers

Simple,

git log branch...origin/branch

Or little more beautiful :

git log --graph --color --decorate --oneline branch...origin/branch
like image 118
hspandher Avatar answered Nov 05 '22 00:11

hspandher