git rebase basics

前端 未结 2 1210
生来不讨喜
生来不讨喜 2020-11-30 20:27

I have started using git rebase recently and am not 100% certain I\'m doing it right. For the sake of the question, there are two branches in origin, mast

2条回答
  •  日久生厌
    2020-11-30 20:59

    Start with the very simple steps for rebasing your branch with the master; Name;

    git-rebase
    

    Synopsis;

    git rebase [-i | --interactive] [options] [--exec ] [--onto ]
            [] []
    git rebase [-i | --interactive] [options] [--exec ] [--onto ]
            --root []
    git rebase --continue | --skip | --abort | --edit-todo
    

    Description; Assume the following history exists and the current branch is "sample":

     A---B---C sample
             /
        D---E---F---G master
    

    From this point, the result of either of the following commands:

    git rebase master
    git rebase master sample
    

    would be:

    A'--B'--C' sample
                     /
        D---E---F---G master
    

    NOTE: The latter form is just a short-hand of git checkout sample followed by git rebase master. When rebase exits sample will remain the checked-out branch.

    If the upstream branch already contains a change you have made (e.g., because you mailed a patch which was applied upstream), then that commit will be skipped. For example, running ‘git rebase master` on the following history (in which A’ and A introduce the same set of changes, but have different committer information):

    A---B---C sample
             /
        D---E---A'---F master
    

    will result in:

     B'---C' sample
                  /
    D---E---A'---F master
    

    All these were the diagramatic understanding of the rebase process. Once you resolve the conflicts being found after typing git rebase master resolve the conflicts and type git add -u to add the changed codes to the repository. after that perform the command git rebase --continue and continue resolving the conflicts and and repeating the command ;

    git add -u 
    

    and

    git rebase --continue 
    

    until no conflicts being found. At last the final command will be ,

    git push --force origin sample(your branch name)
    

提交回复
热议问题