Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Open Terminal on the Mac and change directories to the repository where you have your branch.
  2. Commit all local changes on your branch.
    git add {changed files}
    git commit -m "Checkpoint commit" 
  3. Get changes from the remote repository. 
    git fetch

  4. Integrate changes from the remote repository into your working copy.
    git rebase origin/master

  5. This lists the names of files that have conflicts, and inserts identifiers directly into those files.

  6. Open each RST file that has a conflict, find the "HEAD" identifiers, fix the conflict, remove the identifiers, and save.
  7. Enter the command: 
    git add <filename>
  8. Iterate through steps 5 & 6 for every file that has a conflict.
  9. Enter the command: 
    git rebase --continue
  10. Enter git status at any time to see the status of your branch. You'll be able to see whether more conflicts remain, or whether your branch is up to date.
  11. When no more conflicts remain, push your changes to the remote repository.

    git push -f

    The -f argument argument to force push is required because the rebase command alters the git history in a way that doesn't match the history on the remote branch. If you try to push without to push without the force argument, git will reject your attempt and suggest that you git you git pull. Don'git pullt git pull, whatever you do.

Reference: Git Rebase Lunch + Learn, also see end of this page for some external references. 

...

  1. Open Terminal on the Mac and change directories to the repo/branch for the PR for which you are squashing commits.
  2. Rebase against master before squashing commits:

    git fetch
    git rebase origin/master

    If you see "Current branch <branchname> is up to date", you're all set. If you see "Your branch and origin/<branchname> have diverged and have x and x different commits each, respectively", you should push your local changes. DO NOT follow the help and git pull.

    git push -f

    You should then see "Current branch <branchname> is up to date"

    Only from this state should you squash commits.


  3. Enter the command: 
    git rebase -i HEAD~3
    where the number after the tilde is the number of commits for your branch. A Sublime/text editor window opens.

  4. The top n lines in the file start with the word "pick", where n is that same number of commits. Skip the first line, and then change "pick" to "squash" or "s" on each subsequent line.
  5. Save the file. Another file Sublime/text editor window opens.
  6. The descriptions you entered for each commit are listed at the top of the file. Delete all but one of them. Edit the description for the single commit to appropriately capture the changes you made in the PR as a whole. Save the file.
  7. Return to Terminal and enter the commandcommands:
    git statusgit push -f
    The PR in Github will refresh to show only one commit, with the description that you chose in Step 56.

    Wait for final tests to run cleanly, then you can merge the PR.


Links