0%

git合并指定文件到另一个分支

问题

练习使用git的分支功能时,

首先,在master下面创建了两个文件readme.md和studyGit.md

image-20200727162806063

然后,在master基础上创建了一个分支newbranch,在newbranch分支下,创建新文件newBranchFile.md,这时newbranch下有三个文件,再将newbranch下的两个文件readme.md和studyGit.md,这个时候newbranch下只剩一个文件newBranchFile.md

image-20200727162903167

最后,我想将newbranch下的文件newBranchFile.md合并到master上去,何解?

答案

1
2
git checkout master
git checkout newbranch newBranchFile.md

这就结束了吗?不,并没有,看看它的git status,你会发现它会让你更新下本地库

image-20200727163042040

那就更新下本地库

1
git commit -m"update master with newbranch file"

参考文献

[1] 周伯通的麦田. Git合并指定文件到另一个分支. cnblogs. 2017. https://www.cnblogs.com/phpper/p/7609238.html