LoginSignup
2
1

More than 5 years have passed since last update.

Gitのオプションことはじめ

Posted at

Gitのオプションことはじめ

自分の備忘録を兼ねて、Gitのコマンドオプションについて概要を記述します。

git config --global alias.(alias-name) (git-command)

新規でエイリアスを作成する。

git add -p

対話モードでステージングセッションを開始する。
より細かい単位でステージングを実現させる。
スクリーンショット 2017-05-08 7.27.59.png

git commit -a

変更があったファイルをステージングせずに、直接コミットする。
ただし、変更対象にあるファイルに限定されるため、新規追加ファイルはコミットされない。

git commit -m "(comment)"

エディタを起動させずに、コミットを行う。

git commit --amend

直前のコミットに、ステージされた変更を結合する。
何もステージされていなければ、コミットログの編集のみを行う。

git log --oneline

ログの内容を一行で表示させる。

git checkout -b (branch)

ブランチを新規作成後、そのブランチにチェックアウトする。
git branch (branch-name) + git checkout (branch-name)

git reset --soft

コミット:直前の内容に一致させる
ステージ:変更なし
ワーキングディレクトリ:変更なし

git reset

コミット:直前の内容に一致させる
ステージ:リセットされる
ワーキングディレクトリ:変更なし

git reset --hard

コミット:直前の内容に一致させる
ステージ:リセットされる
ワーキングディレクトリ:リセットされる

git clean -f

追跡対象外のファイルを削除する。

git clean -df

追跡対象外のファイル/フォルダを削除する。

git branch -d (branch)

ブランチを削除する。

git push (remote) :(branch)

リモートブランチを削除する。

git merge --no-ff (branch)

常にfast-fowardを行わず、マージコミットを作成する。

git rebase -i (base-commit)

対話モードで、現在のブランチを(base-commit)にリベースする。
rebase + コミット順番の変更

git remote -v

接続させているリモートブランチの一覧のURLを表示する。

git pull --rebase (remote)

ローカルブランチをリモートブランチにリベースする。

参考

https://www.atlassian.com/ja/git
http://qiita.com/fnobi/items/ec036c1b5d7ee5a8517c

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