How to view unpushed Git commits
Overview
Git is a free and open-source distributed version control system.
In this shot, we'll learn how to view git commits that have not been pushed to the remote repository.
We can view the unpushed git commits using the git command. It will display all the commits that are made locally but not pushed to the remote git repository.
git log origin/master..HEAD
Example
Let's take a look at an example.
Commands
Below are the commands we will be using:
# create a file and write content with the tee commandecho "This is a test file" | tee test.txt# add all files in current folder to git staging areagit add .# commit all changesgit commit -m "Added test file"# view unpushed git commitsgit log origin/master..HEAD
Command list
Execute the given commands sequentially in the terminal below:
Explanation
- We added a file named
test.txtto a test repository. - We used
git add .to stage the newly created file for the next commit. - We committed the changes using
git commitbut did not push them to the remote repository. - We displayed the unpushed git commits using
git log origin/master..HEAD.
We can view the unpushed commits in the final output of the terminal.