4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitのコマンド(初心者向け)

Last updated at Posted at 2017-09-01

これまでGitを触ったことがなく、Gitの操作を勉強しようと思いGit-itを使用してみたので、
その際に使用したコマンドをメモとして書きます。
Git-itは以下のページからダウンロード
https://nodeschool.io/index.html

#コマンド一覧
※コマンドの<>は入力不要

##Gitの設定

  • バージョンの確認
    git --version

  • 名前の設定
    git config --global user.name "<任意のユーザ名>"

  • Eメールアドレスの設定
    git config --global user.email "<任意のメールアドレス(xxxxxx@xxx.xxx)>"

  • Gitリポジトリの作成
    git init

##Gitの更新

  • ファイルの変更確認/現在のブランチ確認
    git status

  • コミット対象ファイルの指定(個別)
    git add <ファイル名>

  • コミット対象ファイルの指定(全て)
    git add .

  • Gitリポジトリへ保存
    git commit -m "変更の説明文"

  • ファイルの変更内容の確認
    git diff

##GitHubの設定

  • GitHubユーザの設定
    git config --global user.username <GitHubのユーザ名>

  • GitとGitHubのリモート設定(追加)
    git remote add <※任意のリモートサーバ名> <GitHubのリポジトリのURL>
    ※メインのリモートサーバにはoriginをつける慣習がある

  • GitとGitHubのリモート設定(変更)
    git remote set-url <リモートサーバ名> <GitHubのリポジトリのURL>

  • リモートの設定を確認
    git remote -v

##GitとGitHubの連携

  • Gitの内容をGitHubに送信(Push)
    git push <リモートサーバ名> <Gitのブランチ名>

  • GitHubのリポジトリをローカルにクローン
    git clone <GitHubのリポジトリのURL>

  • GitHubの変更を取得(pull)
    git pull <リモートサーバ名> <ブランチ名>
    変更がない場合は「Already up-to-date」と表示される

  • GitHubの変更を確認
    git fetch --dry-run

##Gitのブランチ操作

  • Gitのブランチの作成
    git branch <任意のブランチ名>

  • Gitのブランチの切り替え
    git checkout <ブランチ名>

  • Gitの現在のブランチのブランチ名の変更
    git branch -m <変更後のブランチ名>

  • Gitのブランチ一覧を表示
    git branch

  • Gitのブランチをマージする
    git merge <ブランチ名>

  • Gitのブランチを削除
    git branch -d <ブランチ名>

  • GitHubのブランチを削除
    git push <リモートサーバ名> --delete <ブランチ名

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?