How can I see what I am about to push with git?

前端 未结 14 1910
北恋
北恋 2020-11-27 09:06

Is there a way to see what would be pushed if I did a git push command?

What I\'m picturing is something like the \"Files Changed\" tab of Github\'s \"p

相关标签:
14条回答
  • 2020-11-27 09:11

    One way to compare your local version before pushing it on the remote repo (kind of push in dry-run):

    Use TortoiseGit:
    Right click on the root folder project > TortoiseGit > Diff with previous version >
    for Version 2 choose refs/remotes/origin/master

    0 讨论(0)
  • 2020-11-27 09:12

    Try git diff origin/master..master (assuming that origin/master is your upstream). Unlike git push --dry-run, this still works even if you don't have write permission to the upstream.

    0 讨论(0)
  • 2020-11-27 09:12

    You can list the commits by:

    git cherry -v
    

    And then compare with the following command where the number of ^ equals to the number of commits (in the example its 2 commits):

    git diff HEAD^^
    
    0 讨论(0)
  • 2020-11-27 09:15
    1. If you have write permissions on remote
    git push --dry-run
    
    1. If you do not have write permissions on remote
    git diff --stat HEAD remote/branch
    
    0 讨论(0)
  • 2020-11-27 09:20

    If you are using Mac OS X, I would recommend you get Tower, it's a wonderful program that has made dealing with Git a pleasure for me. I now longer have to remember terminal commands and it offers a great GUI to view, track and solve differences in files.

    And no, I'm not affiliated with them, I just use their software and really like it.

    http://www.git-tower.com/

    0 讨论(0)
  • 2020-11-27 09:22

    There is always dry-run:

    git push --dry-run
    

    It will do everything except for the actually sending of the data.

    If you want a more graphical view you have a bunch of options.

    Tig and the gitk script that come with git both display the current branch of your local copy and the branch of the remote or origin.

    alt text

    So any commits you make that are after the origin are the commits that will be pushed.

    Open gitk from shell while in the branch you want to push by typing gitk&, then to see the difference between what is on the remote and what you are about to push to the remote, select your local unpushed commit and right-click on the remote and choose "Diff this -> selected": alt text

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