Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if latest commit to master has been pushed to the remote?

I have merged a branch in to master and now I can see that in my git log

Some time has passed and now I want to know whether I previously also pushed master (with that commit) to the remote. How can I tell if it has been pushed?

I can think of a few workaround such as recloning the repository elsewhere, or resetting and checking and then re-merging but I feel that there's probably a somewhat simpler answer.

fyi this is different from How can I know in git if a branch has been already merged into master? as I know it has been merged, just don't know about the remote push.

like image 835
Michael Durrant Avatar asked Feb 24 '14 13:02

Michael Durrant


People also ask

How do I see recent commit changes?

Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.

Does git push automatically push to master?

Now, just typing git push on the master branch will automatically push to origin/master .

How do I check my master commits?

To confirm, you can run git branch . The branch that you are on will be the one with a * next to it. Git checkout might fail with an error message, e.g. if it would overwrite modified files. Git branch should show you the current branch and git log master allows you to view commit logs without changing the branch.


1 Answers

Do

> git status 

If the output is

# On branch master nothing to commit, working directory clean 

Then you have pushed the current commit.

If the output instead begins with

# On branch master # Your branch is ahead of 'origin/master' by 1 commit. #   (use "git push" to publish your local commits) 

Then you have a local commit that has not yet been pushed. You see this because the remote branch, origin/master, points to the commit that was last pushed to origin. However, your branch is ahead of 'origin/master', meaning that you have a local commit that has been created after the last pushed commit.

If the commit you are interested in is not the latest, then you can do

> git log --decorate --oneline 

to find out if the commit in question is before or after the commit pointed to by origin/master.
If the commit is after (higher up in the log than) origin/master, then it has not been pushed.

like image 126
Klas Mellbourn Avatar answered Sep 30 '22 22:09

Klas Mellbourn