0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

github ことはじめメモ

Last updated at Posted at 2019-03-31

github使う時に最初にやること

# 初期化
git init

# 設定
git config user.name ユーザー名
git config user.email eメールアドレス

##########################################
# ssh接続したい場合(HTTPSだと毎回ログイン情報を問い合わせられる)
# 1: ローカルで公開鍵と秘密鍵を生成します
#   -t: 暗号化方式 -b:鍵の長さ -C:コメント githubではメールアドレス
#   最初にsshキーの保存場所、次にパスフレーズの入力を求められます
ssh-keygen -t rsa -b 4096 -C "メールアドレス"

# 2: sshの保存先にid_rsa(秘密鍵)とid_rsa.pub(公開鍵)が保存されているので
#    公開鍵をgithubに設定する  
#    右上のアカウントメニュー→SSH and GPG keys→new SSH key


# 3: gitbashでgithubに接続する
ssh -T git@github.com

# 以下の内容を聞かれます
# yesを入力
Are you sure you want to continue connecting (yes/no)? yes
# パスフレーズを入力
Enter passphrase for key 'sshキーを保存した場所/.ssh/id_rsa':
# Hi xxxxxx! You've successfully authenticated, but GitHub does not provide shell access.
##########################################

# 追加 
git add -A   

# コミット
git commit -m "initialize repository"

# remote
git remote add origin リポジトリurl

# push
git push -u origin --all
# git addとcommitを同時に
git commit -a -m "Improve the README file"

間違って消してしまった場合

直前のコミットの内容でローカルリソースで上書き

git checkout -f

branch作って、ソース編集 masterにマージ

# branch作成し、選択
git checkout -b ブランチ名

# branchの一覧を表示(確認用)
git branch

###### ソース編集

# add & commit
git commit -a -m "コミットメッセージ"

# masterに切り替え
git checkout master

# branchをmasterにマージ
git merge branch名

# branchを削除。ただし、残しておいても問題はない
# 
git branch -d ブランチ名

Herokuにデプロイ

# 前提条件: 最初の手順でssh接続設定している
# heroku CLIをインストールしている

# ログイン
heroku login

# アプリケーション作成
heroku create

# herokuにデプロイ
git push heroku master
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?