Skip to content

Instantly share code, notes, and snippets.

@hiropppe
Last active November 16, 2017 00:31
Show Gist options
  • Save hiropppe/1654b4f36b39abdb948c to your computer and use it in GitHub Desktop.
Save hiropppe/1654b4f36b39abdb948c to your computer and use it in GitHub Desktop.
Gitリポジトリを他のリモートリポジトリにプッシュする
## 本家をクローン
[root@docker-host gitbucket_workspace]# git clone https://github.com/......../fork-test.git
[root@docker-host gitbucket_workspace]# cd fork-test/
[root@docker-host fork-test]# git tag
release_0.0.1
release_0.0.2
[root@docker-host fork-test]# git branch
* master
[root@docker-host fork-test]# git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/release_0.0.1
remotes/origin/release_0.0.2
[root@docker-host fork-test]# git checkout -b release_0.0.1 remotes/origin/release_0.0.1
Branch release_0.0.1 set up to track remote branch release_0.0.1 from origin.
Switched to a new branch 'release_0.0.1'
[root@docker-host fork-test]# git checkout -b release_0.0.2 remotes/origin/release_0.0.2
Branch release_0.0.2 set up to track remote branch release_0.0.2 from origin.
Switched to a new branch 'release_0.0.2'
[root@docker-host fork-test]# git branch
master
release_0.0.1
* release_0.0.2
## 事前に作成した、piccoloリポジトリをリモートリポジトリに追加
[root@docker-host fork-test]# git remote add piccolo http://192.168.1.10:18080/gitbucket/git/takeshita/fork-test.git
## ブランチとタグをpiccoloリポジトリにプッシュ
[root@docker-host fork-test]# git push --all piccolo
[root@docker-host fork-test]# git push --tags piccolo
# 本家にリリース(更新)があったら
## 更新をフェッチ
[root@docker-host fork-test]# git fetch
[root@docker-host fork-test]# git tag
release_0.0.1
release_0.0.2
release_0.0.3
[root@docker-host fork-test]# git branch
master
release_0.0.1
* release_0.0.2
[root@docker-host fork-test]# git branch -a
master
release_0.0.1
* release_0.0.2
remotes/piccolo/master
remotes/piccolo/release_0.0.1
remotes/piccolo/release_0.0.2
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/release_0.0.1
remotes/origin/release_0.0.2
remotes/origin/release_0.0.3
## リリースブランチをチェックアウト
[root@docker-host fork-test]# git checkout -b release_0.0.3 remotes/origin/release_0.0.3
Branch release_0.0.3 set up to track remote branch release_0.0.3 from origin.
Switched to a new branch 'release_0.0.3'
[root@docker-host fork-test]# git branch
master
release_0.0.1
release_0.0.2
* release_0.0.3
## ブランチとタグをpiccoloリポジトリにプッシュ
[root@docker-host fork-test]# git push --all piccolo
[root@docker-host fork-test]# git push --tags piccolo
# 新しくpiccoloリポジトリをクローンしたワークスペースのリモートに本家を追加して追従
git clone http://192.168.88.180:18080/gitbucket/git/u_hiroki_takeshita/github_fork_test.git
cd github_fork_test/
git remote add github https://github.com/hiropppe/gitoptest.git
## 本家で更新が発生
git fetch github
git pull github master
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment