LoginSignup
1
0

More than 3 years have passed since last update.

GitHubへのpushまでの流れ

Posted at



githubへpushを勉強したのでアウトプットします。

前提

開発環境 AWScloud9

やること

  • githubにアカウント登録(飛ばす)
  • リモートリポジトリを作成(ここも飛ばす)
  • ssh公開鍵を登録
  • pushしたいディレクトリをgit管理下に置く
  • pushするディレクトリをcommitする
  • リモートリポジトリの登録
  • githubへpushする

ssh公開鍵の登録

githubに登録する用の秘密鍵/公開鍵のペアを作成する。

$ cd~/.ssh
$ ssh-keygen
#色々と入力が求められるが空欄でEnterでも可能
$ cat ~/.ssh/id_rsa.pub

作成した公開鍵の内容を表示し、コピペしてgithubに登録。


pushしたいディレクトリをgit管理下に置く

githubにpushしたいディレクトリに移動して下のコマンドを実行するとディレクトリをgit管理下に置くことができる。

$git init


pushするディレクトリをcommitする

#このコマンドで対象をステージングエリアへ(git addの後に続く「.(ピリオド)」は、今のディレクトリ配下全てのファイルという意味)
$git add . 

#このコマンドでローカルリポジトリへコミットする。 -mの後はコミットメッセージ
$git commit -m "コミットメッセージ"



リモートリポジトリを登録する

#以下のコードでリモートリポジトリを登録する
$git remote add origin git@github.com:アカウント名/リポジトリ名.git

※間違ったリモートリポジトリを登録してしまった場合

#以下のコマンドで変更可能
$git remote set-url <リポジトリの名前> <新しいリポジトリのURL>

#以下のコマンドでリモートリポジトリのURLを確認できる
$ git remote -v


githubにpushする

#以下のコマンドでpushできる
$git push -u origin master



参考
http://tetsuyai.hatenablog.com/entry/20110912/1315798082

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