2
2

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 pullしてきたときに "git pull origin 自分のいるブランチ" するコマンド

Last updated at Posted at 2017-05-18

適当に pull と push を作りました。
pushについてはy/nとかつけたほうが良さそうな気もしますが、今はつけてないです

~/.bash_profile
git_branch() {
  echo $(git branch --no-color 2>/dev/null | sed -ne "s/^\* \(.*\)$/\1/p")
}
alias pull='git pull origin `echo $(git_branch)`'
alias push='git push origin `echo $(git_branch)`'

git_branch()はechoで今いるブランチを出力するだけの関数で、これをgit pull originに足してあげることでoriginの入力を省略してます。

pullした時の例

$ pull
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), done.
From github.com:aaaaa/iiiii
 * branch              develop    -> FETCH_HEAD
   ***********  develop    -> origin/develop
Updating ***********
Fast-forward
 path/to/filename | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

git pullしたときの挙動を今自分がいるブランチに直す方法がわからなかったので自分でつくりました。
誰かもっといい方法知っていたら教えてください〜

2
2
3

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?