log.saiias

あてにならない備忘録

gitの使い方

ローカルでの作業

レポジトリの作成

$ git init

ファイルの追加

$ git add .

ファイルのコミット

$ git commit -am "Comment"

ファイルの削除

$ git rm ファイル名

ファイルのインデックスから削除

$ git rm --cached ファイル名

ブランチの作成

$ git branch ブランチ名
$ git checkout -b ブランチ名

ブランチの移動

$git checkout ブランチ名

ブランチのマージ

$ git merge マージするブランチ

変更されたファイルの表示

$ git status

コミットのログを表示する

$ git log
.gitignore

ここにレポジトリに追加する必要のないファイルを記載すると、記載したファイルを無視する。またワイルドカードによる記述も可能。
.ignoreの例

test.txt
*.exe

リモートレポジトリ

ベアレポジトリの作成

$ git init --bare
ローカルでの作業

サーバの登録

$ git remote add origin gitサーバー:パス

ファイルのプッシュ(ブランチを作成した場合はブランチもpushする必要あり)

$ git push origin master


クローン作成

$ git clone gitサーバー:パス フォルダ名

最新版の取得

git pull

普段の使い方

  1. レポジトリの作成(git init)p
  2. ファイルの追加(git add .)
  3. ファイルのコミット(git commit)
  4. 変更がうまく行ったらマージ(git merge)
  5. サーバにプッシュ(git push)