LoginSignup
3
2

More than 5 years have passed since last update.

MacOs, LinuxでのGitコマンド 

Posted at
  • gitのバージョンをチェック

    
    $ git --version
    
  • gitのユーザー設定

    
    $ git config --global user.name "[ユーザー名]"
    $ git config --global user.email "[アドレス]"
    
  • gitの出力をカラーリング

    
    $ git config --global color.ui auto
    
  • gitコマンドのエイリアスを設定

    
    $ git config --global alias.[エイリアス] [コマンド]
    
  • ローカルリポジトリの作成

    
    $ git init
    
  • ファイルの変更をコミットする


$ git add [ファイル名]
$ git commit -m "[コミットメッセージ]"

# インデックスのバリエーション
$ git add .   # gitが管理する全てのファイルをインデックス
$ git add -u  # 最新のコミットから変更があったもの全てインデックス
  • 現在のブランチとインデックスの状態を確認

$ git status

# 現在のブランチを表示
On branch master

# インデックスしていない変更がある場合
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

    modified:   sample.txt

no changes added to commit (use "git add" and/or "git commit -a")

# インデックスしているがコミットしていない変更がある場合
Changes to be committed:
  (use "git rm --cached ..." to unstage)

    new file:   sample.txt

# 最新のコミット以後変更がない場合
nothing to commit, working directory clean
  • ファイルの編集履歴を確認
    
    $ git log

  • リモートリポジトリをローカル環境にクローン
    
    $ git clone [リモートリポジトリのURL] [ディレクトリ名]

  • リモートリポジトリからローカルにプル
    
    $ git pull orgin master

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