LoginSignup
2
2

More than 5 years have passed since last update.

【自分用】Gitまとめ

Last updated at Posted at 2016-01-12

git ステージング操作

全ての変更をステージングに追加する

git add -all

ステージングの状態を確認する

git status

git commit 操作

コミットする(メッセージ付き)

git commit -m "メッセージ"

コミットログの一覧

git log

-n でで指定した部分だけのコミットログを表示する

git branch 操作

ブランチのチェックアウトと作成

git checkout -b <ブランチ名>

ブラントのチェックアウト

git checkout <ブランチ名>

ブランチの削除

git branch -d <ブランチ名>
git branch -D <ブランチ名>

-d または –delete はマージされたブランチは削除できる
-D は容赦なく(irrespective)ブランチを削除する

リモーブランチの削除

git push <リモート> :<ブランチ名>

Gitのクローン

git clone <リモートリポジトリ> <クローン先>

ファイル、フォルダの名前変更

Gitでは小文字大文字の変更を認識しない、そのため下記のコマンドでファイル名を変更する必要がある。

git mv -f <旧ファイル名> <新ファイル名>

フォルダは一旦別名に変更する必要がある。
※ファイルの名前変更でも有効。

git mv <旧フォルダ名> <一時的なフォルダ名>
git commit .
git mv <一時的なフォルダ名> <新フォルダ名>
git commit .

git stash 操作

作業途中の内容を一時退避

git stash save <メッセージ>

退避された一覧

git stash list

退避された内容の適用

git stash apply <stash番号>

退避された内容の削除

git stash drop <stash番号>

git reset 操作

ひとつ前のコミットを削除する

git reset --hard HEAD^
2
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
2
2