間違いだらけの備忘録

このページの内容は無保証でありこのページの内容によって直接、または間接に損害を受けられたとしても私は責任を取りません。

gitでカレントブランチをpushする

https://qiita.com/mabots/items/76d48aa33720287253bf

下記を実行することで、カレントブランチ (git st で確認)の内容を origin に対して push できます。

git push origin HEAD
[alias]
p = !git push -u origin `git rev-parse --abbrev-ref HEAD`

remote指定、最新commitのtag付き

ptag = "!f () { git push ${1:-origin} `git rev-parse --abbrev-ref HEAD`; git push ${1:-origin} `git describe --tags --exact-match`;}; f"

git pull時に下記が表示されることへの対策
http://mashi.hatenablog.com/entry/2012/09/17/170023

merge with, and 'branch.newbranch.merge' in your configuration file does
not tell me, either. Please specify which branch you want to use on the
command line and try again (e.g. 'git pull '). See
git-pull(1) for details.
(中略)
実はpushするときに -u オプションをつければ勝手に設定が追加される
git push -u origin newbranch

まとめ

ブランチ作成後の初回pushの際は-uオプションをつけよう

以下は古い記述

http://qiita.com/tkengo/items/5bae50fb7531d5a6bbcf

[alias]
  p = !git push origin `git rev-parse --abbrev-ref HEAD`

! を最初に置いとくと、シェルのコマンドを書けます。
このページにはhatena以外のサービスからのコンテンツが埋め込まれています。 hatenaによりGoogle AdSense 広告が埋め込まれています。