0
0

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 1 year has passed since last update.

よく使用するGitコマンド

Posted at

はじめに

GitHubにソースコード変更履歴を残す際に使用する主なGitコマンドをアウトプットします.

git init : ローカルリポジトリの新規作成

リポジトリとは,ファイルの変更履歴を記録する場所.カレントディレクトリに「.git」ディレクトリが生成され,この中で変更履歴の情報が管理される.

git remote add : ローカルリポジトリをリモートリポジトリに登録

リモートリポジトリとは,オンライン上で変更履歴を管理する場所.GitHubが代表的.

使い方

$ git remote add origin リモートリポジトリのURL

リモートリポジトリにoriginという名前でアクセスできるようになる.originの部分は任意の名前をつけることができる.

git add : ファイルの変更をステージングエリアへ追加

ステージングエリアとは,コミットするための控室.
git add [ファイル名]で対象ファイルを追加.
git add .でローカルリポジトリ内の全ファイルを追加できる.

git commit : ローカルリポジトリにコミット

ステージングエリアに追加した変更履歴を,ローカルリポジトリに記録する.

使い方

$ git commit -m "コメント"

-m "コメント"を追加で書くことで,コメントを付与することができる.

git push : リモートリポジトリにプッシュ

ローカルリポジトリの内容をリモートリポジトリに送信する.

使い方

git push origin master

originというリモートリポジトリに,masterブランチを送信するという意味.

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?