GGG

プログラミング言語やソフトウェア開発について思ったことを書いてます

よく使う?最近使ったgit command

これまでGitの操作はSourceTreeによるGUI操作が多かった。

転職して職場が変わったらCUI操作がメインになった。

ここ最近、使ったコマンドを一覧にしてみた。

Git command

一覧

command Description
git init カレントディレクトリにリポジトリ生成
git add --all ステージへ全てのファイルを追加する
git reset ステージ上のファイルをUnstageする
(コミット対象から外す)
git remote add origin <remote-repository-pass> リモートリポジトリ名 origin へ <remote-repository-pass>を追加
git push -u origin --all 登録している origin へリモートリポジトリへ push
git push origin --tags ローカルで付けたタグを全てリモートリポジトリへ反映させる
git push origin <タグ名>
git checkout -b <branch-name> ブランチ名<branch-name>のブランチを生成し、<branch-name>へチェックアウトする
git checkout -f 作業内容をクリアして、直前のコミットの状態にする。
git checkout <branch-name>  ブランチ名<branch-name>をチェックアウトする
git branch ブランチ一覧を表示する。
git branch -d <branch-name> ブランチ名<branch-name>を削除する
git status 変更状態を表示する。
git commit -m "You write something here for what you modify." メッセージをコマンドライン上で指定しコミットする。
git log 過去のコミットメッセージを表示する。
git merge <branch-name> 現在のブランチにブランチ<branch-name>をマージする。
git rm --cached <file-name> gitのトラック対象から外す
git tag <タグ名> タグ <タグ名> をセットする
git reset HEAD <ファイル名> 「git add (ステージング)」した<ファイル名>を取り消す(アンステージする)

リポジトリの生成

カレントディレクトリにリポジトリを生成する
$ git init 

ステージ , アンステージ

ステージに移動する
$ git add --all
アンステージする
$ git reset

リポジトリ状態表示

git status

リポジトリのトラック対象から除外

$ git rm --cached foobar.txt

リモートリポジトリとして<remote-repository-pass>登録

git remote add origin <remote-repository-pass> 

コミット

コマンドラインにコミットメッセージを含めてコミットする
git commit -m "You write something here for what you modify."