Git - 每个分支的单独文件夹。设置它 [英] Git - separate folder for each branch. Setting it up

查看:1143
本文介绍了Git - 每个分支的单独文件夹。设置它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在3个单独的文件夹中保留3个分支。 (我知道这不是一种做事的方式,但我需要这样做)。

假设回购股份名称为 my_proj_repo.git
我在本地系统中创建了一个名为 prodv1 的文件夹:

  git克隆网址:/my_proj_repo.git 

现在我进入 prodv1 文件夹并从服务器复制文件,然后:

  git commit -aminitial import
git push origin master

把文件推送给主人。
现在我在本地系统中创建了两个类似上面的文件夹

  stagingv1 
devv1

我想创建两个本地和远程分支,名称如下:

  staging //这个本地分支点(推/拉)到staging远程分支
dev //这个本地分支点((推/拉)到dev远程分支

这两个分支应该位于相应的文件夹中:

  staging ==> stagingv1文件夹
dev ==> devv1文件夹

我尝试了一些东西,我想我把它搞砸了。
有人可以指点命令/步骤来获得所需的所有设置吗?



我所做的是,进入 stagingv1 文件夹并执行 git clone< repo> 。但是它默认为 master 。我不知道如何在这里初始化分段分支。

解决方案

我认为您可能需要在您的仓库中创建所有分支

  $ git分支< name_of_your_new_branch> 

然后创建您的所有文件夹并在您的每个文件夹中克隆回购站但签出适当的分支。 / p>

每个文件夹应该只可以跟踪相应的分支

 步骤1 $ git branch [name_branch#1] 

步骤2 $ git branch [name_branch#2]

步骤3 $ git branch [name_branch#3]

...

 步骤4 $ git push --all 
步骤5 md文件夹#2
步骤6 $ git clone [URL]
步骤7 $ git checkout [name_branch]


I have a need to keep 3 branches in 3 separate folders. (I know this is not a git way of doing things. But I need to do this for a reason).

Lets say the repo name is my_proj_repo.git I have created a folder called prodv1 in my local system:

git clone url:/my_proj_repo.git

Now I went into prodv1 folder and copied the files from a server, then:

git commit -am "initial import"
git push origin master

That pushed the files to master. Now I created two more folders like the above in my local system

stagingv1
devv1

I want to create two local and remote branches with the names:

staging // this local branch points (push/pull) to staging remote branch
dev     // this local branch points ((push/pull) to dev remote branch

And these two branches should be in the corresponding folders:

staging ==> stagingv1 folder
dev     ==> devv1 folder

I tried a few things and I guess I messed it up. Can someone point me commands/steps to get all this setup like I wanted?

What I did was, went into the stagingv1 folder and did a git clone <repo>. But it defaults to master. And I am not sure how to initialize the staging branch here.

解决方案

I think that you might have to create all the branch in your repo

$ git branch <name_of_your_new_branch>

Then create all your folders and in each of your folder Clone the repo but Checkout the appropriate branches.

Each folder should / may track only the appropriate branch

Step 1 $ git branch [name_branch#1]

Step 2 $ git branch [name_branch#2]

Step 3 $ git branch [name_branch#3]

...

Step 4 $ git push --all
Step 5 md Folder #2
Step 6 $ git clone [URL]
Step 7 $ git checkout [name_branch]

这篇关于Git - 每个分支的单独文件夹。设置它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆