git 如何将 SourceTree 中的分支移动到文件夹中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30401763/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:14:08  来源:igfitidea点击:

How to move branch in SourceTree into Folder?

gitatlassian-sourcetree

提问by stevek

I have the following branch structure in git:

我在 git 中有以下分支结构:

master 
feature-2
bugfix/bug-1
feature/feature-1

Now I want to move branch feature-2into the featurefolder.

现在我想将分支移动feature-2feature文件夹中。

How do I move branches into folders? Either via SourceTree or the git command line.

如何将分支移动到文件夹中?通过 SourceTree 或 git 命令行。

回答by pkamb

SourceTree seems to display "folders" for branches that have the same folder/structurein their branch names.

SourceTree 似乎为folder/structure分支名称相同的分支显示“文件夹” 。

You should simply create a new branch called feature/feature-2pointing at the same commit as your current feature-2branch. Then push the new branch and delete the old one.

您应该简单地创建一个名为feature/feature-2指向与当前feature-2分支相同的提交的新分支。然后推送新分支并删除旧分支。

You can name your branches in a folder structure-like format and they appear as folders in SourceTree. For example you could name it as features/issue_1539and SourceTree will display featuresas a folder.

您可以以类似文件夹结构的格式命名分支,它们在 SourceTree 中显示为文件夹。例如,您可以将其命名为features/issue_1539,SourceTree 将显示features为一个文件夹。

https://answers.atlassian.com/questions/200282/sourcetree-categorize-branches

https://answers.atlassian.com/questions/200282/so​​urcetree-categorize-branches

回答by Alexey Andrushkevich

You can rename this branch:

您可以重命名此分支:

git branch -m feature-2 feature/feature-2

You can also create new branch and delete the old one:

您还可以创建新分支并删除旧分支:

git checkout feature-2
git checkout -b feature/feature-2
git branch -d feature-2