Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 将分支合并到新存储库中_Git_Github_Git Merge - Fatal编程技术网

Git 将分支合并到新存储库中

Git 将分支合并到新存储库中,git,github,git-merge,Git,Github,Git Merge,假设我在哪里有这样一个git分支sampath test。我从主repo创建了这个分支。我已经创建了另一个新的存储库(master),比如ionic3-refactured。这个新的master存储库只有一个自述文件。那么,您能告诉我如何将sampath测试代码合并到freshmasterrepoionic3重构?您可以使用它 git push <path to repository> <local branch name>:<remote branch name&

假设我在哪里有这样一个git分支
sampath test
。我从
主repo
创建了这个分支。我已经创建了另一个新的存储库(
master
),比如
ionic3-refactured
。这个新的
master
存储库只有一个自述文件。那么,您能告诉我如何将
sampath测试
代码合并到fresh
master
repo
ionic3重构

您可以使用它

git push <path to repository> <local branch name>:<remote branch name>
下面创建一个新的存储库,并将
newbranch
与它的历史一起推到其中:

$ mkdir ../newrepo

$ cd ../newrepo/

$ git init
Initialized empty Git repository in /home/chuckx/code/stackoverflow/gitpush/newrepo/.git/

$ cd ../repo1/

$ git push ../newrepo/ branch1:newbranch1
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 596 bytes | 596.00 KiB/s, done.
Total 7 (delta 1), reused 0 (delta 0)
To ../newrepo/
 * [new branch]      branch1 -> newbranch1

$ cd ../newrepo/

$ git branch
  newbranch1

$ ls

$ git checkout newbranch1
Switched to branch 'newbranch1'

$ ls
file1.txt  file2.txt  file3.txt  README

$ git log | grep -v Author
commit bbdbd16488f835ee9bd0903274e45d18b0e621a1
Date:   Sun Jun 10 01:02:53 2018 -0700

    Add file3.txt

commit 56cd34350e846b92762d16af1c777ff4075fff3e
Date:   Sun Jun 10 01:02:23 2018 -0700

    Add file1.txt and file2.txt

commit c5d453a847d3b61b75f8a27de3b3cdc163421398
Date:   Sun Jun 10 01:01:55 2018 -0700

    Add README

也许吧,虽然我真的不明白你想做什么,但这个链接对你的情况应该有帮助。我添加了更多的内容。也请看一下
$ mkdir ../newrepo

$ cd ../newrepo/

$ git init
Initialized empty Git repository in /home/chuckx/code/stackoverflow/gitpush/newrepo/.git/

$ cd ../repo1/

$ git push ../newrepo/ branch1:newbranch1
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (7/7), 596 bytes | 596.00 KiB/s, done.
Total 7 (delta 1), reused 0 (delta 0)
To ../newrepo/
 * [new branch]      branch1 -> newbranch1

$ cd ../newrepo/

$ git branch
  newbranch1

$ ls

$ git checkout newbranch1
Switched to branch 'newbranch1'

$ ls
file1.txt  file2.txt  file3.txt  README

$ git log | grep -v Author
commit bbdbd16488f835ee9bd0903274e45d18b0e621a1
Date:   Sun Jun 10 01:02:53 2018 -0700

    Add file3.txt

commit 56cd34350e846b92762d16af1c777ff4075fff3e
Date:   Sun Jun 10 01:02:23 2018 -0700

    Add file1.txt and file2.txt

commit c5d453a847d3b61b75f8a27de3b3cdc163421398
Date:   Sun Jun 10 01:01:55 2018 -0700

    Add README