How to check for changes on remote (origin) Git repository

后端 未结 8 1759
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 04:12

What are the Git commands to do the following workflow?

Scenario

I cloned from a repository and did some commits of my own to my local reposit

相关标签:
8条回答
  • 2020-12-04 04:49

    You could git fetch origin to update the remote branch in your repository to point to the latest version. For a diff against the remote:

    git diff origin/master
    

    Yes, you can use caret notation as well.

    If you want to accept the remote changes:

    git merge origin/master
    
    0 讨论(0)
  • 2020-12-04 04:49

    I just use

    git remote update
    git status
    

    The latter then reports how many commits behind my local is (if any).

    Then

    git pull origin master
    

    to bring my local up to date :)

    0 讨论(0)
  • 2020-12-04 04:50

    I simply use

    git fetch origin
    

    to fetch the remote changes, and then I view both local and pending remote commits (and their associated changes) with the nice gitk tool involving the --all argument like:

    gitk --all
    
    0 讨论(0)
  • 2020-12-04 04:54

    A good way to have a synthetic view of what's going on "origin" is:

    git remote show origin
    
    0 讨论(0)
  • 2020-12-04 04:56

    My regular question is rather "anything new or changed in repo" so whatchanged comes handy. Found it here.

    git whatchanged origin/master -n 1
    
    0 讨论(0)
  • 2020-12-04 05:05

    One potential solution

    Thanks to Alan Haggai Alavi's solution I came up with the following potential workflow:

    Step 1:

    git fetch origin
    

    Step 2:

    git checkout -b localTempOfOriginMaster origin/master
    git difftool HEAD~3 HEAD~2
    git difftool HEAD~2 HEAD~1
    git difftool HEAD~1 HEAD~0
    

    Step 3:

    git checkout master
    git branch -D localTempOfOriginMaster
    git merge origin/master
    
    0 讨论(0)
提交回复
热议问题