Git fetch/pull/cherry-pick学习

转自:https://www.cnblogs.com/emanlee/p/14832905.html,https://blog.csdn.net/ybdesire/article/details/42145597

https://www.cnblogs.com/todototry/p/4095626.html

1.cherry-pick

从一个分支合并特定的commits到另一个分支:

git cherry-pick commitID

也可以合并另一个分支一系列的分支,之后用到再总结。

2.fetch

 git fetch remote_repo         →→ 更新名称为remote_repo的远程repo上的所有branch的最新commit-id,将其记录。 

 git fetch remote_repo remote_branch_name        →→ 更新名称为remote_repo 的远程repo上的分支: remote_branch_name

 git fetch remote_repo remote_branch_name:local_branch_name       →→ 更新名称为remote_repo 的远程repo上的分支: remote_branch_name ,并在本地创建local_branch_name 本地分支保存远端分支的所有数据。

FETCH_HEAD: 是一个版本链接,记录在本地的一个文件中,指向着目前已经从远程仓库取下来的分支的末端版本。

3.pull

git pull = git fetch + git merge

git pull origin master  // 从远端的master分支拉取

 

首先,基于本地的FETCH_HEAD记录,比对本地的FETCH_HEAD记录与远程仓库的版本号,然后git fetch 获得当前指向的远程分支的后续版本的数据,然后再利用git merge将其与本地的当前分支合并。

git fetch:是从远程获取最新版本到本地,不会自动merge。git pull是从远程获取最新版本并merge到本地仓库。

 

posted @ 2023-03-05 20:45  lypbendlf  阅读(224)  评论(0编辑  收藏  举报