Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

How do I list all commits which have not been pushed to the origin yet?

Alternatively, how to determine if a commit with a particular hash has been pushed to the origin already?

2 Answers

0 votes
by (50.2k points)

For this, you need to use the following commands:

git log origin/master..master

or, more generally:

git log <since>..<until>

For checking the specific known commit you can use grep:

git log <since>..<until> | grep <commit-hash>

you can search for a specific commit using git-rev-list:

git rev-list origin/master | grep <commit-hash>

Or If you have performed a commit but did not push it to any branch. Use this to see what that commit was:

git reflog

0 votes
by (1.3k points)
The following command from your terminal lists all the commits yet to be pushed to origin:

git log origin/main.HEAD

If needed, replace main with your current branch name. This command shows you all commits on your current branch that aren't there on the given remote branch.
 
To know if a particular commit with hash COMMIT_HASH has been pushed you may use
git branch -r --contains COMMIT_HASH
This should return a branch from the remote if this command succeeded and otherwise it failed.

Related questions

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...