LoginSignup
4
3

More than 5 years have passed since last update.

Git CUIとうまく付き合うための便利コマンド一覧 ~設定・確認編~

Last updated at Posted at 2016-09-21

株式会社オズビジョン@terra_yuccoです。
2016年度、enPiTプログラム履修生として、
7月~ 品川シーサイドの産業技術大学院大学にて学んでいます。

職場ではGit/GitHubはTortoiseGitで操作していますが、
講義内ではCUI操作なので、自分のための覚書も兼ねてまとめています。
今回は、初期設定、およびよく使いそうな状態確認周りをまとめました。

環境確認・設定

PCを変えたり再インストールしたりするたびに必要になりそうな設定。
その他GitHubを利用するならssh用鍵の登録も必要。

  • バージョン確認
    • GitHubインターフェースのhubコマンドを入れていると、hub側のバージョンも出ます
    • ここで躓いたらGit - Gitのインストール辺りを参照してインストールから。
$ git --version
git version 1.9.1
hub version 2.2.3
$ # ユーザ名
$ git config --global user.name terra-yucco
$ # メールアドレス
$ git config --global user.email aaa@bbb.ccc
$ # CUI上の色付け設定
$ git config --global color.ui auto
$ # エディタの設定
$ git config --global core.editor vim
$ # Pushのデフォルト設定付け
$ git config --global push.default simple
  • グローバル設定確認
$ git config -l
color.ui=auto
push.default=simple
core.editor=vim
core.autocrl=input
user.email=aaa@bbb.ccc
user.name=terra-yucco

状態確認

現在のワークスペースの状況確認 (git status)

今自分がどのブランチにいるか、ブランチの状態がどうなっているのかを確認できる。

  • 作成したての新規ブランチ
$ git status
On branch new
nothing to commit, working directory clean
  • 新規作成したファイルがあってステージング前
$ touch tutorial.txt
$ git status
On branch new
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        tutorial.txt

nothing added to commit but untracked files present (use "git add" to track)
  • ステージング後、コミット前
$ git add .
$ git status
On branch new
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   tutorial.txt
  • コミット後 (最初に戻る)
$ git commit -m 'test commit'
[new a907804] test commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tutorial.txt
$ git status
On branch new
nothing to commit, working directory clean
  • git show
  • git log
  • git branch -vva

参考リンク

まだWIP

  • git show
  • git log
  • git branch -vva

このあたりの詳細は次の版で自分用に書きます!

おしまい。


Git CUIとうまく付き合うシリーズ

4
3
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
4
3