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
Let's take a look at an example.
Below are the commands we will be using:
# create a file and write content with the tee command echo "This is a test file" | tee test.txt # add all files in current folder to git staging area git add . # commit all changes git commit -m "Added test file" # view unpushed git commits git log origin/master..HEAD
Execute the given commands sequentially in the terminal below:
test.txtto a test repository.
git add .to stage the newly created file for the next commit.
git commitbut did not push them to the remote repository.
git log origin/master..HEAD.
We can view the unpushed commits in the final output of the terminal.
View all Courses