如何将一个从github分支将文件夹切成同一分支中的另一个文件夹 从这个问题中ththank到@jthill: 将其所有历史记录的Git分支中的文件夹转换或复制一个新的Git分支 我使用此git命令将一个从github源分支将文件夹切成

问题描述 投票:0回答:1
I使用此git命令将一个文件夹从github源分支切成另一个分支,并将文件夹的提交历史记录保留在源分支中:

git clone <repo-line> git switch Source-Branch a=$( git commit-tree -p heads/Source-Branch -m "Slice folder from a branch." heads/Source-Branch:Source-Folder ) git update-ref refs/heads/New-Branch $a git status git switch New-Branch git status git push -u origin New-Branch

如何使用相同的方法,但是这次我想将一个文件夹从github分支切成一个文件夹到同一分支中的另一个文件夹并维护提交历史记录?

I发现了如何在新文件夹中的同一分支中复制文件夹并维护提交历史记录:

git clone <url> git switch source-branch a=$(git commit-tree -p heads/source-branch -m "Slice folder to prepare for copy with commit history" heads/source-branch:source-folder) git update-ref refs/heads/temp-branch $a git branch -vv mkdir new-folder touch new-folder/readme.md git add . commit -m "Commit new folder to prep for copy." git merge --allow-unrelated-histories --no-commit -Xsubtree=new-folder temp-branch git status git add . git commit -m "Commit a copy of source-folder with commit history." git log --oneline git push origin
git github
1个回答
0
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.