Git and GitHub concepts: Reviewing updated pull requests locally

前端 未结 2 2029
傲寒
傲寒 2021-01-29 04:09

I follow the generic OSS structure:

  1. the OSS\' remote repository hosted on GitHub
  2. a fork of the OSS remote repository to my own remote repository
2条回答
  •  礼貌的吻别
    2021-01-29 05:04

    You can use any of below options to update the PR in local repo.

    Option 1: delete the local source branch and recreate to get the update

    As you use the commands to get the source branch of the PR locally:

    git fetch upstream pull//head:
    git checkout 
    

    If the PR is updated (new commits are pushed to the fork repo), you can delete and recreate by:

    git checkout master
    git branch -D 
    git fetch upstream pull//head:
    git checkout 
    

    Option 2: add the fork repo as a remote for your local repo

    You can add the fork repo as a remote for your local repo by

    git remote add fork1  -f
    

    Then you can create a local branch for the PR source branch by

    git checkout -b  fork1/
    

    If the PR has been updated, you just need to execute below commands to get the update:

    git fetch fork1
    git checkout  #If HEAD is not on the 
    git reset --hard fork1/
    

提交回复
热议问题