How to create local branch based on the remote branch

有时review其他成员的Pull request,或基于另外一个remote branch进行change,我们要checkout remote branch,创建本地branch。

  1. 当前一般是本地master branch,先fetch一把,将最新remote branches拉到本地,不然识别不了remote branches, Run command: git fetch
  2. 查看所有Fetch到的remote branches, Run command: git branch -r
  3. 基于remote branch,创建local branch并切换到新的branch,一般loca branch名字和remote branch名一样,方便识别。
    Run command: git checkout -b local_branch_name remote_branch_name
    例如:
 git checkout -b feature/apac_story_12345  origin/feature/apac_story_12345
  1. 查看local branch与remote branch的关联, run command: git branch -vv
C:\xxx\Automation>git branch -vv
  master          8023a51e [origin/master] merge from release_major
* feature/apac_story_12345 cbb37931 [origin/feature/apac_story_12345] Merged PR 222001: fixed xxx autoamtion issue

猜你喜欢

转载自blog.csdn.net/wumingxiaoyao/article/details/109688529
今日推荐