0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

VS Codeで既存のGitHubリポジトリを別のリポジトリに変更する方法

Last updated at Posted at 2024-07-18

VS Codeで既存のGitHubリポジトリを別のリポジトリに変更する方法

VS CodeでPlatformIOなどで新規プロジェクトを作成した場合になぜか前のリポジトリと紐図いたままになっていることがよくあるのでリポジトリの変更方法をメモします。

1. コマンドラインを使ってリモートリポジトリのURLを変更

  1. VS Codeのターミナルを開きます(Ctrl + または Cmd + )。

  2. 以下のコマンドを実行して現在のリモートリポジトリを確認します。

    git remote -v
    
  3. リポジトリが異なる場合リポジトリを初期化します。

    git init
    
  4. リモートリポジトリのURLを変更します。

    git remote add origin 新しいリポジトリのURL
    
  5. 変更が適用されたか確認します。

    git remote -v
    

2. 変更をプッシュ

  1. コードをコミットしていない場合、変更をコミットします。

    git add .
    git commit -m "コミットメッセージ"
    
  2. 新しいリモートリポジトリにプッシュします。

    git push -u origin main
    

これで、VS CodeでのリポジトリのURL変更が完了です。新しいリポジトリへの変更内容がプッシュされます。

0
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?