0
1

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 5 years have passed since last update.

作業ブランチが汚いときでもシュッとmasterにpullしたい

Posted at

カレントブランチに未コミットな差分があると、他のブランチをチェックアウトできません。そこでいったん git stash やってからチェックアウトして git pull しますが、これ面倒ですよね。

というわけで git fetch で、カレントでないローカルブランチに直接リモートのコミットを落としてきます。

git fetch -u origin master:master
-u, --update-head-ok
By default git fetch refuses to update the head which corresponds 
to the current branch. This flag disables the check. This is purely 
for the internal use for git pull to communicate with git fetch, 
and unless you are implementing your own Porcelain you are not 
supposed to use it.

リモートのブランチが多いのでそれ GUI で一覧から選んで指定するの大変で、ってときに都合いいですね。

また、カレントブランチはクリーンな状態でも、リベースの時とかいちいち切り替えて戻ってやってワーキングのファイルをごちゃごちゃ書き換えするよりは、こうやって...

git fetch -u origin master:master
git rebase -i master
0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?