135 | | |
| 135 | ==== Updating your PR from master ==== |
| 136 | |
| 137 | Updating your PR from master is often referred to as rebasing a PR. It comes into play in case there are |
| 138 | changes 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 | {{{ |
| 141 | git fetch upstream |
| 142 | git rebase upstream/master |
| 143 | git status |
| 144 | }}} |
| 145 | |
| 146 | Now the //git status// will tell you that your local branch and the branch in origin (which is your fork) have diverged: |
| 147 | |
| 148 | {{{ |
| 149 | Your branch and 'origin/fix-window-size' have diverged, |
| 150 | and have 7 and 5 different commits each, respectively. |
| 151 | }}} |
| 152 | |
| 153 | If 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) |
| 157 | error: failed to push some refs to 'https://...' |
| 158 | hint: Updates were rejected because the tip of your current branch is behind |
| 159 | }}} |
| 160 | |
| 161 | Besides 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 | |
| 163 | As //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 | |
| 165 | To 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 | {{{ |
| 168 | git push --force origin fix-window-size |
| 169 | }}} |
| 170 | |
| 171 | If 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`. |