0
0

More than 3 years have passed since last update.

Git クローンしたリポジトリ[ローカル]を別リポジトリ[リモート]にpush

Posted at

題名の通り、
クローンしたリポジトリ[ローカル]を別リポジトリ[リモート]にpushするやり方を知ったので
アウトプットしていこうと思います。

流れ[図]

Untitled (Draft)-1 2.jpg

■クローン

$ git clone -b main https://github.com/kazuya424/testproject.git test

■作成したtestフォルダに移動

$ cd test

■remote urlの確認

$ git config remote.origin.url
https://github.com/kazuya424/testproject.git

■remote urlの変更

$ git remote set-url origin https://github.com/kazuya424/test.git

■再度remote urlの確認

$ git config remote.origin.url
https://github.com/kazuya424/test.git

■ブランチ作成

$ git branch -M main

■ブランチ確認

$ git branch
* main

■push

$ git push -u origin main
Username for  ユーザーネーム入力
Password for  パスワード入力
Counting objects: 3, done.
Writing objects: 100% (3/3), 243 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/kazuya424/test.git
 * [new branch]      main -> main
Branch main set up to track remote branch main from origin.

追加(testリポジトリ[ローカル]を変更し、pushまで)

今回用いるエディタはVSCode。
上記で作成したtestフォルダを開く。

VSCodeで「新しいターミナル 」を開く。

push先がtestリポジトリか確認し、異なる場合は変更。

$ git config remote.origin.url
https://github.com/kazuya424/testproject.git

$ git remote set-url origin https://github.com/kazuya424/test.git

$ git config remote.origin.url
https://github.com/kazuya424/test.git

■ブランチ作成

$ git branch develop

■developブランチに移動

$ git checkout develop

■ブランチ確認

$ git branch

■内容変更

あとはお決まりのプッシュまでの流れ

$ git status

$ git add.

$ git commit -m “コミット名”

$ git push origin develop

参考

https://k-koh.hatenablog.com/entry/2020/10/09/154644

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0