Changes between Version 87 and Version 88 of DeveloperGuidelines/Git

01/02/14 15:17:28 (10 years ago)
Pat Tressel



  • DeveloperGuidelines/Git

    v87 v88  
    127127Regardless of whether you rebase or merge, neither of these is a "safe" operation -- you may make a mistake
    128128during the process, or encounter errors or conflicts.  So before starting, a simple way to be sure you can
    129 go back to your unmodified branch is to make a copy of the branch.  This assumes you are working on branch
    130 mychanges and want to save your work on branch mychanges_backup, and that you have a remote called upstream
    131 that points to the trunk repository:
     129go back to your unmodified branch is to make a copy of the branch.
     131The following summary of commands assumes you are working on branch mychanges and want to save your work on
     132branch mychanges_backup.  It also assumes you have a master branch that mirrors branch master in trunk, and
     133that you have a remote called upstream that points to the trunk repository.  This setup makes it less
     134convenient to use the {{{git pull --rebase}}} command, as that (now) requires that the remote and local
     135branch have the same name.  Here we show an alternative that does a pull into your local master branch, then
     136a rebase from your updated master branch into your mychanges branch.
    134139# Check whether you have uncommitted changes
    135 git log
     140git status
    137142# Commit any new and changed files
    142147git checkout -b mychanges_backup
     149# Update your master branch (this is assumed to have only trunk commits on it)
     150git checkout master
     151git pull upstream master
    144153# Switch back to the branch you want to update
    145154git checkout mychanges
    147 # Update your branch from trunk
    148 git pull --rebase upstream master:mychanges
     156# Update your mychanges branch from your (updated) local master
     157git rebase master
     159# If you get a conflict on one of your commits, the rebase will stop and leave files with the
     160# conflicts marked.  See the following section about how to resolve it.  After you have edited
     161# any files that need to be changed, git add them and optionally commit them, then continue the
     162# rebase.
     163# Edit as per next section...
     164git add ...
     165git rebase --continue
     167# If, at any point before the end of the rebase, something goes wrong, or you're just not sure
     168# what you're doing:
     169git rebase --abort
    149171==== Resolving Merge Conflicts ====
    150172If you encounter conflicts during the rebase, the conflicts will be tagged in the files with: