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

カテゴリー: GitHub  閲覧数:559 配信日: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'.


週間人気ページランキング / 11-14 → 11-20
順位 ページタイトル抜粋 アクセス数
1 開発 0 4
2 GitHubリモートリポジトリ名には日本語を使用できない。使用すると、ハイフンへ自動置換されてしまう | GitHub(Git) 3
3 ログイン 1
3 Twitter連携ログイン代替APIを探しています | Webサービス開発 1
3 Twitter API (Twitter) カテゴリー 1
3 Create New App / アプリケーション登録 1
3 個人事業主が導入可能な決済系サービス2次選考過程第1段階 | 決済(Webサービスビジネス) 1
3 コインチェック株式会社   | Webサービスビジネス 1
3 Q1.「Twitter API」は必ずユーザ認証させる必要がある? 自分のデータを取得する場合はユーザ認証画面へ遷移させる必要はない? 1
3 電話番号認証を新規で行う(SMSメールを受信する)度に、(以前の該当アカウントでは)下記メールを受け取る 1
3 RSS購読解除履歴 | RSS(プログラミング) 1
3 大前提 / これまで / 自分で作成することを決意 1
3 Twitter API 1.0 | Twitter API 旧仕様(Twitter) 1
3 何やってたか履歴 | プログラミング 1
3 「Twitter Developers」でアプリケーションを新規作成するためには? SMS認証用コードを確認可能な電話番号の登録が必要 | Twitter Developer(Twitter) 1
3 アクセス数が少ない Webサイト(開発ブログ) を非公開へ変更 | Webサービス開発 1
3 気になるアプリ | ブックマーク 1
3 mhtmlの問題 | Google Chrome 拡張機能 1
3 Twitterデータ 対応 第1版 / 第1版 更新 1
3 Q2.About multiple applications 1
2025/11/21 1:02 更新
指定期間人気ページランキング / 2020-5-27 → 2025-11-20
順位 ページタイトル抜粋 アクセス数
1 GitHubリモートリポジトリ名には日本語を使用できない。使用すると、ハイフンへ自動置換されてしまう | GitHub(開発環境) 1068
2 fatal: remote error: is not a valid repository name | Git BASH(開発環境) 748
3 Twitter アカウント管理 | Twitter Developer(Twitter) 621
4 開発 0 605
5 Twitter API | Twitter API (Twitter) 598
6 動画対応 | プログラミング 590
7 「Twitterデータ」対応 | Twitter Developer(Twitter) 563
8 Windows10で使用できるGitクライアント | GitHub(開発環境) 461
9 本 | ブックマーク 451
10 Webサービス | ブックマーク 424
11 マッチングサービス | Webサービスビジネス 403
12 同じ携帯電話番号でも、複数の「Twitter Developers」アカウントを作成可能 | Twitter Developer(Twitter) 366
13 TwitterOAuth では、画像URL を指定した画像投稿は出来ない(と思う)。ライブラリを使用しなければ出来るから、Twitter API の制限ではない(と思われる)  | Twitter 327
14 teratailでは質問しない | プログラミング 301
15 技術書籍 | プログラミング 300
16 気になった動画 | ブックマーク 294
17 埋め込みツイート | Twitter Developer(Twitter) 271
18 個人事業主 | Webサービスビジネス 250
19 Twitter 電話番号の問題 | Twitter Developer(Twitter) 234
20 コインチェック株式会社   | Webサービスビジネス 216
2025/11/21 1:02 更新