å³ã§åããgit-rebase
ä¸éçã«ãGitã¯ã³ããããã°ãæ¸ãæãããã¦ãã¢ããã¨è¨ãããè©èº«ãçãã®ã§ git-rebase ã®èª¬æãæ¸ãã¦ã¿ãã
git help ããå¼ç¨
ã¾ãã¯åºæ¬ã«å¿ å®ã«ããã«ããèªã¿ã¾ãããã
- git help rebase
SYNOPSIS git rebase [-i | --interactive] [options] [--onto <newbase>] <upstream> [<branch>] git rebase [-i | --interactive] [options] --onto <newbase> --root [<branch>] git rebase --continue | --skip | --abort DESCRIPTION If <branch> is specified, git rebase will perform an automatic git checkout <branch> before doing anything else. Otherwise it remains on the current branch. All changes made by commits in the current branch but that are not in <upstream> are saved to a temporary area. This is the same set of commits that would be shown by git log <upstream>..HEAD (or git log HEAD, if --root is specified). The current branch is reset to <upstream>, or <newbase> if the --onto option was supplied. This has the exact same effect as git reset --hard <upstream> (or <newbase>). ORIG_HEAD is set to point at the tip of the branch before the reset. The commits that were previously saved into the temporary area are then reapplied to the current branch, one by one, in order. Note that any commits in HEAD which introduce the same textual changes as a commit in HEAD..<upstream> are omitted (i.e., a patch already accepted upstream with a different commit message or timestamp will be skipped). It is possible that a merge failure will prevent this process from being completely automatic. You will have to resolve any such merge failure and run git rebase --continue. Another option is to bypass the commit that caused the merge failure with git rebase --skip. To restore the original <branch> and remove the .git/rebase-apply working files, use the command git rebase --abort instead.
ãã«ãèªãã§ãããªãã»ã©ï¼ãã¨æã£ãæ¹ã¯ããã®ã¾ã¾ãã©ã¦ã¶ã®ã¿ããéãã¦å¤§ä¸å¤«ã§ãã
ãã®å
ã«git-help 以ä¸ã®æ
å ±ã¯ããã¾ããã
git-helpãè²¼ã£ãã ãã ã¨ãgit-rebaseãã¢ããã®ä¸è«ã¯å¤ãããªãã¨æãã®ã§ãåºæ¬çãªæãåãããããæ¥æ¬èªã§æ¸ãã¦ã¿ã¾ããã
git-rebase ã®æ¦è¦
ã¾ãã¯git-rebase ã®å¼æ°ã«ã¤ãã¦èª¬æãã¾ãã
- åºæ¬çãªæ§æ*1
$ git rebase [--onto <newbase>] <upstream> [<branch>]
å¼æ°ã¯3ã¤ããã¾ãã
--onto
- çç¥å¯ãçç¥æã¯
ã¨åãã - æå®ã¯
ãªãã¸ã§ã¯ãï¼ãã©ã³ãåãã¿ã°åãããã·ã¥å¤ãHEAD@{n}ã»ã»ã»ãªã©ï¼
- å¿ é ã
- æå®ã¯
ãªãã¸ã§ã¯ãï¼ãã©ã³ãåãã¿ã°åãããã·ã¥å¤ãHEAD@{n}ã»ã»ã»ãªã©ï¼
- çç¥å¯ãçç¥æã¯current branchï¼ä»ãããã©ã³ãï¼ã¨åãã
- æå®ã¯
ãªãã¸ã§ã¯ãï¼ãã©ã³ãåãã¿ã°åãããã·ã¥å¤ãHEAD@{n}ã»ã»ã»ãªã©ï¼
git-rebase ã®å¦çã®æµã
㨠ã®å ±éã®ç¥å ãæ¢ãã - <å
±éã®ç¥å
>ãã
ã¾ã§ã³ãããã¨åãå¤æ´ã ã«è¿½å ãã¦ããã ããã©ã³ãåãªãããã©ã³ãã®åç §ãHEADã«åè¨å®ããã
ï¼ã¤ãã¤ãå³ã交ãã¦ãé çªã«èª¬æãã¾ãã
0. æåã®ç¶æ
ä¾ã¨ãã¦ããããªã³ããããã°ãããã¨ãã¾ãã
ãã®ã¨ãããããªã³ãã³ããæã£ãã¨ããã
$ git rebase master topic
1. å ±éã®ç¥å ãæ¢ã
git-rebase ã¯ãã¾ãå
±éã®ç¥å
ï¼å³ã®èµ¤ãç®æï¼ãæ¢ãã¾ãã
2. å¤æ´ãã«è¿½å
次ã«ã<å
±éã®ç¥å
>ãã
ä»å㯠--onto ãªãã·ã§ã³ãæå®ãã¦ããªãããã
- å¤æ´ç®æã
ã«è¿½å ãã
3. ãã©ã³ãã®åç §ã®æ´æ°
æå¾ã«ã
以ä¸ãgit-rebase ããã£ã¦ããå¦çã§ãã
--onto ãããå ´å
ä¸è¿°ãããgit-rebase ã®å¦çã®æµããã¨åãã§ãã
å®éã«ã³ãã³ããæã£ã¦ãåèªã§ç¢ºèªãã¦ã¿ã¦ãã ããã
$ git rebase --onto master topicA topicB $ git log --oneline --decorate --graph --all
ãã¶ããã³ããããã°ãâã®ããã«å¤ããã¯ãã§ãã
- git-rebaseå
- git-rebaseå¾
gitk
git-rebase ã«æ £ãã¦ããªãéã¯ãgitk ã常ã«èµ·åããã¦ãããgit-rebaseåå¾ã確èªããæ¹ãè¯ãã§ãã
$ gitk --all &
ä»ã®ãªãã·ã§ã³ã«ã¤ãã¦
ä»ã®ãªãã·ã§ã³ã®èª¬æã¯è²ããªæ¹ãæ¢ã«ããã°ãªã©ã«æ¸ãã¦ããã®ã§ãã°ã¼ã°ã«å çã«èãã¦ãã ããã
*1:ç§ã¯ãgit rebase <ã³ã³ã«> <ãããã> <ããã¾ã§>ãã§è¦ãã¦ã¾ããããããããããã¾ã§ã®å¤æ´ããã³ã³ã«è¿½å ãããã¨ããæãã§