git remoteで設定したリモートURLを変更する

はじめに

githubでリポジトリを作成して、

https://github.com/ki-hi-ro/python

ローカルで、git initを行った。

(venv) Mac:python shibatahiroshitaka$ git init
Reinitialized existing Git repository in /Users/shibatahiroshitaka/Downloads/python/.git/

補足情報として書いておくと、以下のコマンドで、venvを起動している。

Mac:python shibatahiroshitaka$ source venv/bin/activate

git remote add originをしようとしたら、すでにリモートオリジンが存在しているというエラーが出た。

(venv) Mac:python shibatahiroshitaka$ git remote add origin https://github.com/ki-hi-ro/python.git
error: remote origin already exists.

現在のgit remoteを確認する

(venv) Mac:python shibatahiroshitaka$ git remote -v
origin  http://localhost:8080/git/root/eki-api.git (fetch)
origin  http://localhost:8080/git/root/eki-api.git (push)

以前の記事でローカルのGitBucketをリモートに設定していた。

現在のgit remoteを変更する

(venv) Mac:python shibatahiroshitaka$ git remote set-url origin https://github.com/ki-hi-ro/python.git
(venv) Mac:python shibatahiroshitaka$ git remote -v
origin  https://github.com/ki-hi-ro/python.git (fetch)
origin  https://github.com/ki-hi-ro/python.git (push)

リモートリポジトリに必要なファイルを上げた

https://github.com/ki-hi-ro/python

.gitignore

venv
others
.DS_Store

git status、git add、git commit、git push

(venv) Mac:python shibatahiroshitaka$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        bfs-short.py
        bfs.py
        eki-api/
        requirements.txt

nothing added to commit but untracked files present (use "git add" to track)

(venv) Mac:python shibatahiroshitaka$ git add bfs-short.py requirements.txt

(venv) Mac:python shibatahiroshitaka$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   bfs-short.py
        new file:   requirements.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        bfs.py
        eki-api/

(venv) Mac:python shibatahiroshitaka$ git commit -m "最短経路探索"
[master (root-commit) 5ed9d4f] 最短経路探索
 2 files changed, 81 insertions(+)
 create mode 100644 bfs-short.py
 create mode 100644 requirements.txt

(venv) Mac:python shibatahiroshitaka$ git push origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.30 KiB | 1.30 MiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/ki-hi-ro/python.git
 * [new branch]      master -> master

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です