git-rebase ãå¤ç¨ããéçºã®æµã
git-rebase ã使ã£ãéçºã®æµããåºã¾ã£ã¦ããã®ã§ãããã°ã§æãã¦ã¿ã¾ãã
ãã®åãããæ¥æ°ãçµã£ã¦ããçç±ã¯å¯ãã¦ãã ããã
ã¨ããããããã°ãã»ã¼ãã¯2é±ãã¦ãé»ééå£å£«ã¯2åæç ´ãã¾ããã
ã¾ãåãã«
- git-rebase ã«ä¸æ £ããªæ¹ã¯çä¼¼ããªãæ¹ãããã§ã
- reflog ã§git-rebase ã®å¤±æãæ»ããªã人ãçä¼¼ããªãæ¹ãããã§ã
- ç¡åãã©ã³ãã«ç§»åãã¦ãæ³£ããªãããã«
éçºã®æµã
åæ
- git-pull ã¯ä½¿ãããgit-fetch ã使ã
- 追跡ãã©ã³ãã§ã¯ä½æ¥ãããªãï¼å¿ ããããã¯ãã©ã³ããä½ãï¼
- bashã«gitã®ãã©ã³ãåã表示ãã¦ããï¼rebaseã§ã³ã³ããªã¯ãèµ·ããã®ãè¦ããªãã¨å±éºãªã®ã§ï¼
0. ä½æ¥æºå
ããã¸ã§ã¯ãã®ãã£ã¬ã¯ããªã«ç§»åããã
$ cd ~/Projects/FizzBuzz
ä½æ¥åã«ãªã¢ã¼ããªãã¸ããªã®å¤æ´ãåå¾ããã
$ git fetch
ãã®å¾ãgitk ãèµ·åãã¦ãã
$ gitk --all &
1. ä½æ¥çæ
ä½æ¥ããããã«ããããã¯ãã©ã³ããä½ãã¾ãã
ãããã¯ãã©ã³ãã¯å¿
ããªã¢ã¼ãã®ãã©ã³ãããä½ãã¾ãã
$ git checkout -b feature/foo origin/develop
2. ä½æ¥ä¸
ä½æ¥ã¯å¿
ããããã¯ãã©ã³ãã§è¡ãã¾ãã
ãããã¯ãã©ã³ãã®ã³ããããã°ã¯ä¸æ¸ããªã®ã§ã綺éºã«æ¸ãã¦ããé©å½ã«æ¸ãã¦ããgit-nowï¼tmp コミットのための独自サブコマンド git-nowï¼ã§ãæ§ãã¾ããã
2.1. ä½æ¥ä¸ã«ãªã¢ã¼ãã®å¤æ´ãåå¾ãã
ä½æ¥ä¸ã«ãªã¢ã¼ãã®å¤æ´ãæ°ã«ãªã£ãå ´åãgit-fetchã§ãªã¢ã¼ãã®å¤æ´ãåå¾ããã
git-pull ã¨éãããã¼ã¸ãçºçããªããããæ°è»½ã«fetchã§ããã
2.2. ä»ã®ä½æ¥ã«å¿ è¦ãªå¤æ´ãpushããã¦ããå ´å
git-fetch å¾ã«ãã°ã確èªããå¤æ´ãå¿ è¦ã§ããã°git-rebase ã§å¤æ´ãåãè¾¼ã¿ã¾ãã
$ git fetch $ git log --oneline -n 10 origin/develop $ git rebase origin/develop
3. ä½æ¥çµäº
ãããã¯ãã©ã³ãã§ã®ä½æ¥ãçµãã£ãããã³ããããæ´çããã
æ´çãããã¤ã³ãã¯2ç¹ã§ãã
- ããã¸ã§ã¯ãã®ä»ã¡ã³ãã¨ã³ãããã®ç²åº¦ãåããã
- ã³ããããã°ã®æç« ãæ´å½¢ããï¼å¤æ´ã®æå³ãåãããããã±ããçªå·ããããã誤åã»è±åãã§ãã¯...etcï¼
ã¾ãã¯ãä½æ¥ä¸ã®ä»ã®äººã®å¤æ´å 容ãåå¾ãã¾ãã
$ git fetch
ãã®å¾ãã³ããããæ´çãã¾ãã
$ git rebase -i origin/develop
4. ä½æ¥çµäºã®ç¢ºèª
rebase ã§å¤±æãã¦ããªãããgitk ã§ç¢ºèªãã¾ãã
4.1. git-rebase ã§å¤±æããå ´å
ããæå³ããã³ããããã°ã«ãªã£ã¦ããªãå ´åãreflogï¼ãããã¯gitkï¼ã¨git-resetã使ã£ã¦æ»ãã¾ãã
5. å¤æ´å 容ã追跡ãã©ã³ãã«åæ ãã
ã3. ä½æ¥çµäºãã®git-rebase ãçµããã¨ãä»ãããã©ã³ãã¯ãããã¯ãã©ã³ãã«ãªãã¯ãã§ãã
ããã§developãã©ã³ãã«ãããã¯ãã©ã³ãã®å
容ãåæ ããã¾ãã
$ git rebase HEAD develop
6. 追跡ãã©ã³ãã«åæ ããå 容ã®ç¢ºèª
gitk ã§ç¢ºèªããã
åºæ¬çã«ãgit-rebase ã®å¾ã¯gitk ã§æå³ãããã°ã«ãªã£ã¦ããã確èªããã
7. ä½æ¥å 容ãpushãã
ã5. å¤æ´å
容ã追跡ãã©ã³ãã«åæ ããããçµããã¨ãä»ãããã©ã³ãã¯developã«ãªãã¯ãã§ãã
ããã§ãgit-push ããã¾ãã
$ git push
ã¾ã¨ã
ã¡ãªãã
- git-fetch ã ã¨æ°è»½ã«ãªã¢ã¼ãã®å¤æ´ãåå¾ã§ãã
- ãããã¯ãã©ã³ãã®ã³ããããã°ãå¿ ãæ¸ãæããã®ã§ãä½æ¥ä¸ã¯ãã°ã«æããªãã¦è¯ã
- git-rebase ãå¤ç¨ããã¨git-checkout ãæ¸ã£ã¦ãã¿ã¤ãæ°ãæ¸ã
- git rebase -i, git rebase HEAD, git pushã®ãã³ããè¯ã
ãã¡ãªãã
- git-rebase ã¯Windowsã ã¨é ã
- git-rebase ã«ä¸æ £ãã ã¨æé ãã¹ã£ãæã«æ³£ããããªã
ã¾ã¨ãï¼140æåï¼
ã¨ã¤ãªã¢ã¹ãè¨å®ãã¦ããã¨ããããªæé ã§ãã
- ã¨ã¤ãªã¢ã¹ã®è¡¨
ã¨ã¤ãªã¢ã¹ | ã³ãã³ã |
---|---|
ft | fetch |
co | checkout |
rb | rebase |
rbh | rebase HEAD |
ps | push |