Viewing unpushed Git commits

前端 未结 25 2346
Happy的楠姐
Happy的楠姐 2020-11-22 08:05

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

相关标签:
25条回答
  • 2020-11-22 08:48

    one way of doing things is to list commits that are available on one branch but not another.

    git log ^origin/master master
    
    0 讨论(0)
  • 2020-11-22 08:50

    As said above:

    git diff origin/master..HEAD

    But if you are using git gui

    After opening gui interface, Select "Repository"->Under that "Visualize History"

    Note: Some people like to use CMD Prompt/Terminal while some like to use Git GUI (for simplicity)

    0 讨论(0)
  • 2020-11-22 08:51

    git branch -v will show, for each local branch, whether it's "ahead" or not.

    0 讨论(0)
  • 2020-11-22 08:52

    This worked for me:

    git cherry -v 
    

    As indicated at Git: See all unpushed commits or commits that are not in another branch.

    0 讨论(0)
  • 2020-11-22 08:52

    Handy git alias for looking for unpushed commits in current branch:

    alias unpushed = !GIT_CURRENT_BRANCH=$(git name-rev --name-only HEAD) && git log origin/$GIT_CURRENT_BRANCH..$GIT_CURRENT_BRANCH --oneline
    

    What this basically does:

    git log origin/branch..branch
    

    but also determines current branch name.

    0 讨论(0)
  • 2020-11-22 08:52

    I had a commit done previously, not pushed to any branch, nor remote nor local. Just the commit. Nothing from other answers worked for me, but with:

    git reflog
    

    There I found my commit.

    0 讨论(0)
提交回复
热议问题