If I have a local branch test
and the remote branch is test
. So if I did a push it would be push origin test:test
How can I see my local unpushed commits that I did on that branch? git log
?
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.
The commit history can be viewed in different ways by using the `git log` command. A local repository named bash has been used in this tutorial to test the commands used in this tutorial. Run the following command to view the commit history of the repository.
To review the changes before pushing, you can look at the History view. E.g. when you have unpushed commits on the master branch, you will see origin/master in the history pointing to the latest commit that is known on the remote repository. On top of that, you will see your local commits and the label for master.
If your excess commits are only visible to you, you can just do git reset --hard origin/<branch_name> to move back to where the origin is. This will reset the state of the repository to the previous commit, and it will discard all local changes.
I generally use gitk --all
for that (after a git fetch --all
).
And, for console mode, I have an alias of git log --graph --all --decorate --oneline
which gives a nice and compact overview of your branches. In particular, it shows what you can push.
For both these commands you can specify branches (test origin/test
in your case) instead of showing them all with --all
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With