How to preview git-pull without doing fetch?

前端 未结 8 2030
天涯浪人
天涯浪人 2020-11-29 14:41

Is it even possible?

Basically, there\'s a remote repository from which I pull using just:

git pull

Now, I\'d like to preview what

8条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 15:16

    If you don't want git-fetch to update your local .git, just copy your local repo to a temp dir and do a pull there. Here is a shor-hand:

    $ alias gtp="tar -c . | (cd /tmp && mkdir tp && cd tp && tar -x && git pull; rm -rf /tmp/tp)"
    

    Ex.:

    $ git status
    # On branch master
    nothing to commit (working directory clean)
    
    $ gtp
    remote: Finding sources: 100% (25/25)
    remote: Total 25 (delta 10), reused 25 (delta 10)
    Unpacking objects: 100% (25/25), done.
    From ssh://my.git.domain/reapO
       32d61dc..05287d6  master     -> origin/master
    Updating 32d61dc..05287d6
    Fast-forward
     subdir/some.file       |    2 +-
     .../somepath/by.tes    |    3 ++-
     .../somepath/data      |   11 +++++++++++
     3 files changed, 14 insertions(+), 2 deletions(-)
    
    $ git status
    # On branch master
    nothing to commit (working directory clean)
    
    $ git fetch
    remote: Finding sources: 100% (25/25)
    remote: Total 25 (delta 10), reused 25 (delta 10)
    Unpacking objects: 100% (25/25), done.
    From ssh://my.git.domain/reapO
       32d61dc..05287d6  master     -> origin/master
    
    $ git status
    # On branch master
    # Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.
    #
    nothing to commit (working directory clean)
    

提交回复
热议问题