Changes between Version 89 and Version 90 of HowToGit


Ignore:
Timestamp:
04/09/20 06:36:30 (5 years ago)
Author:
wenzeslaus
Comment:

Section about rebasing PR with details on strange messages and commands

Legend:

Unmodified
Added
Removed
Modified
  • HowToGit

    v89 v90  
    133133Continue do your changes and commit/push them (ideally to a feature branch, see above).
    134134
    135 
     135==== Updating your PR from master ====
     136
     137Updating your PR from master is often referred to as rebasing a PR. It comes into play in case there are
     138changes in master you need to incorporate into your (feature or fix) branch before the PR can be merged, you need to rebase your branch to upstream:
     139
     140{{{
     141git fetch upstream
     142git rebase upstream/master
     143git status
     144}}}
     145
     146Now the //git status// will tell you that your local branch and the branch in origin (which is your fork) have diverged:
     147
     148{{{
     149Your branch and 'origin/fix-window-size' have diverged,
     150and have 7 and 5 different commits each, respectively.
     151}}}
     152
     153If you try to push to your fork (origin), you will get rejected:
     154
     155{{{
     156 ! [rejected]  fix-window-size -> fix-window-size (non-fast-forward)
     157error: failed to push some refs to 'https://...'
     158hint: Updates were rejected because the tip of your current branch is behind
     159}}}
     160
     161Besides the provided information, both of the messages above will also suggest you to use //git pull// to update. That's not what you want to do (at least not with the default settings of //git pull// which does merge).
     162
     163As //git status// says, there are different commits in each branch (the local one and the one in your fork). That's because //git rebase// changed hashes and dates of the existing commits in your local branch (because it reapplies the changes as new commits on top of the up-to-date upstream). The commits on the branch in your fork don't actually contain anything you don't have, so you can safely discard them. You can confirm this by looking at //git log// locally and looking at the branch in your fork on !GitHub.
     164
     165To push into the branch in the fork, you will need to overwrite what is already there, i.e., replace the branch in the fork by content in your local branch. This is done using force push:
     166
     167{{{
     168git push --force origin fix-window-size
     169}}}
     170
     171If you have access to one of the OSGeo repositories (namelly OSGeo/grass in this case), before force pushing, you need be sure that origin points to your fork and not the OSGeo repo. You can check that using `git remote -v`.
    136172== Switching between branches ==
    137173