Git Subtree只有一个文件或目录 [英] Git Subtree only one file or directory
问题描述
我使用如下的Git Subtree:
git subtree add --prefix = directory_destination_path --squash git@bitbucket.org :kicaj / projectname.git master
但是在路径中: directory_destination_path
将所有回购从 projectname.git复制
如何复制到 directory_destination_path only子目录或只有一些文件来自
projectname.git
?
编辑:
还有一个问题:
如何在两个存储库中更新(自动)文件更改仍然相同?这是可能的吗?
如果我明白了,您似乎只想合并到不同存储库的某个目录中,你希望它成为你的仓库中的一个子树。我将在project.git path_of_interest_in_project
中调用感兴趣的目录,并在repo directory_desination_path
中调用目标。
尝试将远程project.git添加为远程,然后在本地检出其某个分支。然后使用 git-subtree split
来拆分你感兴趣的project.git的目录,然后使用子树合并将它合并到你的repo中。
git remote add project git@bitbucket.org:kicaj / projectname.git
git branch project_master project / master
code>
分支project_master现在应该存储您project.git repo的整个历史记录。
然后你需要使用 git-subtrees-split
进程。
git checkout -f project_master
git subtree split --squash --prefix = path_of_interest_in_project -b temp_branch
现在应该有一个名为 temp_branch
的分支,其中只包含您感兴趣的目录。现在您可以执行 git
git checkout -f master $ b -subtree-merge
$ b git subtree merge --prefix = directory_destination_path tem p_branch
这应该在temp_branch中合并到您的主分支中。
I use Git Subtree like below:
git subtree add --prefix=directory_destination_path --squash git@bitbucket.org:kicaj/projectname.git master
But in path: directory_destination_path
copy all repo from projectname.git
How to copy to directory_destination_path
only subdirectory or only some file from projectname.git
?
EDIT:
One more question:
How to update (automatic) files changes in both repositories were still the same? It is possible?
If I understand, you seem to want to only merge in a certain directory of a different repository, and you want it to be a subtree in your repository. I am going to call the directory of interest in the project.git path_of_interest_in_project
and call the destination in your repo directory_desination_path
.
Try adding the remote project.git as a remote, then checking out one of its branches locally. Then use git-subtree split
to split out just the directory of project.git you are interested in. After that merge it into your repo using subtree merge.
git remote add project git@bitbucket.org:kicaj/projectname.git
git branch project_master project/master
The branch project_master should now store the entire history of your project.git repo.
Then you'll need to use the git-subtrees-split
process.
git checkout -f project_master
git subtree split --squash --prefix=path_of_interest_in_project -b temp_branch
There should now be a branch called temp_branch
containing just the directory you are interested in. Now you can perform a git-subtree-merge
to bring it all into your repo.
git checkout -f master
git subtree merge --prefix=directory_destination_path temp_branch
This should merge in the temp_branch into your master branch.
这篇关于Git Subtree只有一个文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!