ローカルリポジトリに、リモートリポジトリを設定する / 「ローカルリポジトリ」を「リモートリポジトリ」へPUSHする

カテゴリー: GitHub  閲覧数:574 配信日:2019-06-21 14:26


ローカルリポジトリに、リモートリポジトリを設定する


git remote add origin
(リモートリポジトリへ反映させる前に、)ローカルリポジトリへ、リモートリポジトリの情報(GitHubリモートリポジトリのアドレス)を追加する
※リモートリポジトリは、GitHub の GUI 経由で事前作成しておく必要がある
$ git remote add origin git@github.com:GitHubユーザー名/GitHubリポジトリ名.git
fatal: remote origin already exists.


git remote -v
ローカルリポジトリに設定されている、リモートリポジトリ内容を一覧表示(URLも表示)
$ git remote -v
origin  git@github.com:GitHubユーザー名/GitHubリポジトリ名.git (fetch)
origin  git@github.com:GitHubユーザー名/GitHubリポジトリ名.git (push)


これで、ローカルリポジトリにリモートリポジトリの設定ができた

「ローカルリポジトリ」を「リモートリポジトリ」へPUSHする


git push origin master
ローカルリポジトリ(masterブランチ)(の変更)を送信して、リモートリポジトリ(「origin」上の同名ブランチ)へ反映させる
$ git push -u origin master
Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
To github.com:GitHubユーザー名/GitHubリポジトリ名.git
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:GitHubユーザー名/GitHubリポジトリ名.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


$ git pull --rebase origin master
Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
From github.com:GitHubユーザー名/GitHubリポジトリ名
* branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: first commit


git push origin master
ローカルリポジトリ(masterブランチ)(の変更)を送信して、リモートリポジトリ(「origin」上の同名ブランチ)へ反映させる
$ git push -u origin master
Enter passphrase for key '/c/Users/user/.ssh/id_rsa':
Enumerating objects: 437, done.
Counting objects: 100% (437/437), done.
Delta compression using up to 8 threads
Compressing objects: 100% (415/415), done.
Writing objects: 100% (436/436), 811.21 KiB | 4.36 MiB/s, done.
Total 436 (delta 49), reused 0 (delta 0)
remote: Resolving deltas: 100% (49/49), done.
To github.com:GitHubユーザー名/GitHubリポジトリ名.git
  b15102d..9074206  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.


週間人気ページランキング / 12-6 → 12-12
順位 ページタイトル抜粋 アクセス数
1 リーディングアプリサービスとなるためには信頼関係など不要。アフィリエイターを使い捨てる戦略が有効 | Webサービスビジネス 2
1 Twitter 電話番号の問題 | Twitter Developer(Twitter) 2
1 $ git log / $ git status / $ git branch 2
1 ユーザコメント一覧ページ 2
1 デザイン カテゴリー 2
2 Q6.Twitter APIで複数アカウントを作成してはだめ? 1
2 User is not Authorized の闇 | Twitter Developer(Twitter) 1
2 既存Twitterアカウントより電話番号を削除すると、どうなるの? 新規アプリ作成する際、再度電話番号を使用したSMS認証が必要になる | Twitter Developer(Twitter) 1
2 Q3.About multiple applications 2 1
2 「User is not Authorized」と「Phone number is already in use for too many accounts and cannot be added to another user.」は連動していない | Twitter Developer(Twitter) 1
2 個人事業主が導入可能な「チャージ、支払、送金」機能を有する決済系サービス簡易表 1
2 地雷API | API(プログラミング) 1
2 「既存Twitterアプリが使用できる」からと言って「Twitter開発者アカウント」を保持しているとは限らない | Twitter Developer(Twitter) 1
2 「Windows10」へ「gitfor windows VERSION 2.22.0」をインストール | GitHub(Git) 1
2 Twitter 複数アカウントでPOSTしたい | Twitter Developer(Twitter) 1
2 開発ブログ / 公開する意味はあるの? / 今後の方針 1
2 Twitter アプリケーション分類 | Twitter Developer(Twitter) 1
2 「Default branch」ではなく「Your branches」 | GitHub(Git) 1
2 最終的に / 動作確認 / 折角作成したのでChromeウェブストアで公開しようと思ったが… 1
2 ログイン 1
2025/12/13 1:02 更新
指定期間人気ページランキング / 2020-5-27 → 2025-12-12
順位 ページタイトル抜粋 アクセス数
1 GitHubリモートリポジトリ名には日本語を使用できない。使用すると、ハイフンへ自動置換されてしまう | GitHub(開発環境) 1072
2 fatal: remote error: is not a valid repository name | Git BASH(開発環境) 749
3 Twitter アカウント管理 | Twitter Developer(Twitter) 622
4 開発 0 608
5 Twitter API | Twitter API (Twitter) 599
6 動画対応 | プログラミング 591
7 「Twitterデータ」対応 | Twitter Developer(Twitter) 567
8 Windows10で使用できるGitクライアント | GitHub(開発環境) 466
9 本 | ブックマーク 452
10 Webサービス | ブックマーク 426
11 マッチングサービス | Webサービスビジネス 404
12 同じ携帯電話番号でも、複数の「Twitter Developers」アカウントを作成可能 | Twitter Developer(Twitter) 370
13 TwitterOAuth では、画像URL を指定した画像投稿は出来ない(と思う)。ライブラリを使用しなければ出来るから、Twitter API の制限ではない(と思われる)  | Twitter 328
14 teratailでは質問しない | プログラミング 303
15 技術書籍 | プログラミング 300
16 気になった動画 | ブックマーク 294
17 埋め込みツイート | Twitter Developer(Twitter) 272
18 個人事業主 | Webサービスビジネス 251
19 Twitter 電話番号の問題 | Twitter Developer(Twitter) 237
20 コインチェック株式会社   | Webサービスビジネス 217
2025/12/13 1:02 更新