Skip to content

Instantly share code, notes, and snippets.

@featherplain
Last active January 30, 2016 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save featherplain/0ea4aa00da6d7d39d26f to your computer and use it in GitHub Desktop.
Save featherplain/0ea4aa00da6d7d39d26f to your computer and use it in GitHub Desktop.

やりかけの作業を一時保存する

$ git stash // 一時保存
$ git stash pop // 元に戻す
$ git stash list // 保存中の作業一覧を確認

直前のコミットを修正

直前のコミットメッセージのみを修正

$ git commit --amend

vim でコミット情報がせてくるので、一番上のコミットメッセージを書き換える

編集したファイルを直前のコミットに含める

$ git status // 必要であれば差分を確認
$ git add -A
$ git commit --amend

対象のコミットを pick から edit に変更

$ git rebase --interactive HEAD~2
$ git commit --amend --no-edit

一番最初のコミットに戻る

$ git rebase --continue
or
$ git log --reverse

ハッシュ値の確認

$ git rev-list HEAD | tail -n 1

リモートリポジトリの情報を更新

プルリクマージ後、リポジトリをリモート側から削除した際に有効

$ git remote update origin --prune

リモートリポジトリのブランチを削除

$ git push origin --delete branch_name

git rebase

トピックブランチ上で作業している場合、master との乖離が出てくる場合がある

$ git rebase master
$ git push -f

git cherry pick

git push

usage: git push [] [ [...]]

-v, --verbose         be more verbose
-q, --quiet           be more quiet
--repo <repository>   repository
--all                 push all refs
--mirror              mirror all refs
--delete              delete refs
--tags                push tags (can't be used with --all or --mirror)
-n, --dry-run         dry run
--porcelain           machine-readable output
-f, --force           force updates
--force-with-lease[=<refname>:<expect>]
                      require old value of ref to be at this value
--recurse-submodules[=<check|on-demand>]
                      control recursive pushing of submodules
--thin                use thin pack
--receive-pack <receive-pack>
                      receive pack program
--exec <receive-pack>
                      receive pack program
-u, --set-upstream    set upstream for git pull/status
--progress            force progress reporting
--prune               prune locally removed refs
--no-verify           bypass pre-push hook
--follow-tags         push missing but relevant tags
--signed              GPG sign the push

git push -u

特定の作業ブランチを git push するとき、二回目以降なら $ git push ではなく $ git push -u が可能 .git/config にローカルとリモートの関係が書き込まれる

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment