github関連
git コマンド一覧:
git --version
gitのバージョン確認
git init
ギットの初期化
(レポジトリが作成されました)
git status
調べる
git add **/*
追加する。(コミットするファイルを選んでいる)
* 全てという意味
git add -A
git commit -m "xxx"
m:メッセージ
git reset --soft HEAD^
戻る
HEAD:今いる場所
^:一個前に戻る
soft:ログだけ (コードは変更しない)
hard:コードも変更したい時
git reflog
変更箇所を指定して戻す。
ex)
git reset --hard HEAD@{xx}
git diff HEAD^
今のコードと一個前のコミットの差分を表示
q で、元の書き方に戻る。
less index.html
コードを表示
vimの抜け方
:wq
レポジトリ:コード、コードの変更履歴の記録場所のイメージ
githubに上げる(push)
git push origin master
githubの最新のものを取得(pull)
git pull origin master
githubの最新のものの情報を得るだけ
git fetch --all
強制的にpushする。
git push origin master -f
めも:
レポジトリーの作成
new repository name→英語で名前を作成
Description :説明
license →MIT
sorcetreeで
add → 参照 →ローカルファイルを参照 →OK
リモートの設定
リモートの設定 → githubのホームページ→Code→clone or downloadからurlコピー
→リモートのURL/パスに貼り付け
初期設定:
git bushを起動
git config --global user.email 自分のメールアドレス
git config --global user.name "自分のユーザー名"
Sign in with your browserをクリック
使用:
githubのwebページで下記作業を行う。
ファイルの作成
Repositories →New
Repository name を設定
Public(一般公開)
Add a README file(説明を書くReadmeファイルを追加出来る)をチェック(必要であれば)
Create repository :Repository作成
今回githubに上げたいファイルで下記作業を行う。
作成した場所で 右クリック
git bush hereをクリック
git status
git init
git add -A
git commit -m "説明文"
git remote add origin URL
例
既に、originがある場合:(error: remote origin already exists.)
既にあるoriginを消す必要がある。
git remote rm origin
git remote add origin URL
git push origin master
githubを確認する。
編集したファイルを更新する場合:
git add -A
git commit -m "説明文"
git push origin master
ブランチの作成
git branch :branchの作成
git branch sub1 :branch のsub1の作成
git checkout sub1 :branchの移動
git branch
git init :新しいgitレポジトリ作成
git add -A :全てのファイルを追加
git commit -m "コメント" :コメントの追加
git push origin sub1 :sub1をプッシュ
ブランチのプル
git checkout xxx :プルしたいブランチに移動
git branch :プルしたいブランチに移動してるか確認
git pull :プルする。 (プログラムを取り込む)