2017-04-20 113 views
0

所以,我有一个分支,我希望添加一个新的分支到刚刚添加到上游的分支。HowTo:将新分支添加到现有分支,然后使用新分支作为模板创建新项目

我的地方分叉项目(GIT远程-v)是:

origin https://github.com/TheoG/este.git (fetch) 
 
origin https://github.com/TheoG/este.git (push) 
 
upstream  https://github.com/este/este.git (fetch) 
 
upstream  https://github.com/este/este.git (push)

目前我用叉子(原产地),以创建新的项目如下:

1. Create a new repository, called NewProject, on Github (But do not clone) 
 
2. git clone -o upstream https://github.com/TheoG/MyProjFork.git NewProject 
 
3. cd NewProject 
 
4. git remote add origin https://github.com/TheoG/NewProject.git 
 
5. git push origin master 
 
6. npm install

但我想现在要做什么,基本上与上述相同,但使用另一分支,它目前并不在我的叉子的存在,最终让我使用的是创建新的项目之一:

5. git push origin master Or git push (-u ?) origin newbranch

所以,我的问题是,这样做的:

git remote add -t newbranch -f upstream https://github.com/este/este.git 
 
git checkout newbranch

在我的叉,然后让我创建一个新的项目使用叉上的新分支作为模板?

+0

_My当地分叉你的意思project_'cloned' –

+0

@DaniSpringer正确的。 – TheoG

回答

0

所以,解决办法是:

a. git fetch upstream (on the forked project) 
 

 
then following process to create a new template project 
 
2. git clone -o upstream https://github.com/TheoG/MyProjFork.git NewProject 
 
3. cd NewProject 
 
4. git branch -a 
 
5. git checkout $branch 
 
6. git remote add origin https://github.com/TheoG/NewProject.git 
 
7. git push -u origin $branch

相关问题