by shigemk2

当面は技術的なことしか書かない

GitHubで、ローカルで作ったリポジトリから新規作成する

f:id:shigemk2:20131208155633j:plain

うまく説明出来ないのだけれど…
ローカルで作ったリポジトリをgithubに初めてpushする方法

通常の流れ

  1. GitHubでレポジトリ作成
  2. git clone
  3. ローカルでコードをごにょごにょしてコミット
  4. git push

今回やりたいこと

  1. ローカルでgit initしてコードをごにょごにょしてコミット
  2. GitHubでレポジトリ作成
  3. そのレポジトリにgit push

1. ローカルでレポジトリ作成

$ git init
$ git add .
$ git commit -m "This is 1st commit"

2. GitHubでレポジトリ作成

(これは普通にGitHubから)

3. リモートリポジトリを追加する(たぶんココが肝)

ローカルでリポジトリを作ったけど、このままだとgit pushしても
「どこのリポジトリにpushしようとしてるの?」
となるので、以下のコマンドを実行してリモートを指定する。

$ git remote add origin git@github.com:user-name/repository

user-nameとrepositoryは適当に。

FYI:
transitive.info - git remote 使い方

リモートリポジトリを加える

URL が url の名前 remote-name のリモートリポジトリを加えるには

git remote add remote-name url

4. GitHubのリポジトリをローカルに引っぱる

(そのままgit pushしようとすると

There is no tracking information for the current branch.
Please specify which branch you want to merge with.

ってなるから↓のようにしないといけない。

$ git fetch
$ git merge origin/master
$ git push

それで作ったのがこのソースコードです。
shigemk2/.tmux.conf · GitHub