2
1

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 2019-11-17

サーバー上で、修正を反映する時に使うgitコマンドメモです。

###ブランチ確認

git branch

全部ブランチ一覧

git branch -a

###状況確認

git status

###スタッシュ

git stash save "your comment"

###プル

git pull origin master

###ブランチ切り替え

 git checkout [ブランチ名]

※単体ファイルのみ戻す

git checkout [ファイルパス]

###フェッチ
リモートにあるブランチを最新のものに更新します

git fetch

ログ確認

git履歴から対象の文字列(-S メッセージから)を探します

git log -S"hogehoge"

※対象ファイルを絞る場合

git log -S"hogehoge" ./test.java

クローン

対象のリポジトリを自分の環境(ローカル)にもってきます

git clone [クローンしたいリポジトリ] [クローン先のディレクトリ(省略可)]

削除

マージ済みのブランチのみ削除


どちらも同じ
$ git branch --delete [ブランチ名]
$ git branch -d [ブランチ名]

マージ済みのブランチのみ削除ができる
マージされていないブランチを削除しようとすると下記のようなエラーがでます
(error: Cannot delete the branch 'ブランチ名' which you are currently on)
マージされていないブランチを削除したいときは削除コマンド2を

強制削除

$ git branch -D [ブランチ名]

どんなローカルブランチも削除できる

その他

Git で現在のコミット分調べる

git rev-parse HEAD
Git 現地点まで差分とるコマンド
git archive --format=zip --prefix=archive/ HEAD `git diff --name-only [コミットナンバー] HEAD --diff-filter=ACMR` -o archive.zip

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?