Asked  7 Months ago    Answers:  5   Viewed   23 times

How can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always.

Is this a bug with my install of Git, or am I missing something?


git log origin/master..HEAD

You can also view the diff using the same syntax

git diff origin/master..HEAD
Tuesday, June 1, 2021
answered 7 Months ago

Delete the most recent commit, keeping the work you've done:

git reset --soft HEAD~1

Delete the most recent commit, destroying the work you've done:

git reset --hard HEAD~1
Friday, June 11, 2021
answered 6 Months ago
git config --global diff.tool vimdiff
git config --global difftool.prompt false

Typing git difftool yields the expected behavior.

Navigation commands,

  • :qa in vim cycles to the next file in the changeset without saving anything.

Aliasing (example)

git config --global alias.d difftool

.. will let you type git d to invoke vimdiff.

Advanced use-cases,

  • By default, git calls vimdiff with the -R option. You can override it with git config --global difftool.vimdiff.cmd 'vimdiff "$LOCAL" "$REMOTE"'. That will open vimdiff in writeable mode which allows edits while diffing.
  • :wq in vim cycles to the next file in the changeset with changes saved.
Sunday, June 27, 2021
answered 6 Months ago

Looks like fixed with new git version (2.26.2)

git diff-highlight

Saturday, August 14, 2021
answered 4 Months ago

Actually, you can fish this information out of the reflog. It's not the full history of the remote repository but rather it's the history of your copy of the remote repository's branch. So, you will not see changes that were made to the remote repository by other people. It's not pretty, but you can probably write a script to make it easier.

For example:

$ git reflog show origin/master
ca4f119 refs/remotes/origin/master@{0}: pull --rebase: fast-forward
d303ece refs/remotes/origin/master@{1}: pull --rebase: fast-forward
ce28c26 refs/remotes/origin/master@{2}: pull --rebase: fast-forward
0f71883 refs/remotes/origin/master@{3}: pull --rebase: fast-forward
8c2f0dd refs/remotes/origin/master@{4}: pull --rebase: fast forward
2958d6c refs/remotes/origin/master@{5}: update by push
6e9558c refs/remotes/origin/master@{6}: pull --rebase: fast-forward
8854b35 refs/remotes/origin/master@{7}: pull --rebase: fast-forward
b96f25d refs/remotes/origin/master@{8}: pull --rebase: fast-forward
efb0ab8 refs/remotes/origin/master@{9}: pull --rebase: fast-forward
71c12ca refs/remotes/origin/master@{10}: pull --rebase: fast-forward
d860e59 refs/remotes/origin/master@{11}: update by push
6342dbb refs/remotes/origin/master@{12}: fetch: fast-forward

You can see here that my most recent push advanced origin/master from 6e9558c to 2958d6c. To see the commits you can use git log 6e9558c..2958d6c. E.g.,

$ git log --abbrev-commit --pretty=oneline 6e9558c..2958d6c
2958d6c Commit Summary 4
5cbe548 Commit Summary 3
13d007c Commit Summary 2
4f19ac3 Commit Summary 1

If you have terminal access to the remote repository, you could do something similar on that end to see all of the pushes that it received.

Sunday, September 12, 2021
answered 3 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :