0
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 3 years have passed since last update.

Git コマンド一覧

Last updated at Posted at 2020-07-01

リポジトリ

リモートリポジトリを登録

git remote add origin URL

リモートリポジトリURL確認

git remote -v

ブランチ

ローカルブランチの一覧

git branch

リモートブランチ一覧

git branch --remote

ローカル・リモートブランチ一覧

git branch --all

ブランチ作成

git branch ブランチ名

ブランチを新規作成&チェックアウト

git checkout -b ブランチ名

リモートにブランチを登録

git push -u origin ブランチ名

対象ブランチにチェックアウト

git checkout ブランチ名

マージしたブランチ削除

git branch ブランチ名 --delete

マージしたかどうかに関わらず削除

git branch -D ブランチ名

リモートブランチ削除

git push --delete origin ブランチ名

ワーキングツリーの状態確認

普通に表示

git status

短く表示

git status -s

ステージング(インデックスにコミットするファイルを登録)

指定したファイルを登録

git add ファイル名

現在のディレクトリのファイルすべてを登録

git add . 

git addを取り消す

git reset HEAD

スタッシュ

待避にコメントをつける

git stash save コメント

退避させた変更の一覧

git stash list

退避させた最新の変更を戻す

git stash apply

指定する退避させた変更を戻す

git stash apply 番号(git stash list の番号)

applyしたものを取り消す

下記を順に実行
git checkout --ours .
git reset
git checkout .

コミット

コミット

git commit -m コメント(-m コメント)
* -m 2つで2行にできる

前回コミットした時点に戻す

git reset --hard HEAD

特定のコミット時点に戻す

git reset --hard ハッシュ値(git logで確認できる)

一つ前のコミットメッセージを修正する

git --amend -m コメント

プッシュしたコミットメッセージをリモートリポジトリに再プッシュする

git push -f origin ブランチ名

プッシュ

リモートリポジトリにプッシュ

git push origin ブランチ名

強制的にプッシュ

git push -f origin ブランチ名

プッシュを取り消す

git revert コミットID

マージ

ローカルでマージ済ブランチ一覧表示

git branch --merged

対象ブランチをチェックアウト中のブランチへマージ

git merge ブランチ名

新しくマージコミットを作成してマージ

git merge --no-ff ブランチ名

プル

リモートの変更を取得

git pull origin ブランチ名

フェッチ

ローカルに無いリモートブランチ をローカルブランチとして作成

git fetch
git checkout ブランチ名

ローカルの変更を戻す

git checkout ファイル名

タグ

追加

git tag -a タグ -m "コメント"

プッシュ

git push origin タグ名

その他

.gitignore作成

touch .gitignore
0
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
0
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?