问题
I followed the next tutorial https://medium.com/@topspinj/how-to-git-rebase-into-a-forked-repo-c9f05e821c8a
this is my actual repo:
As you can see there are two commits in my pull request and one commit in the original repository.
I want to update my forked repository to bring the changes they made in its last commit
before run the git fetch command to bring the changes my git status tell me:
$ git status
En la rama 13.0
Tu rama está actualizada con 'origin/13.0'.
Then I made git remote add upstream
git remote add upstream https://github.com/original-repo/goes-here.git
and all was Ok.
Then I made git fetch upstream and I got the following result
remote: Enumerating objects: 2556, done.
remote: Counting objects: 100% (2556/2556), done.
remote: Total 3297 (delta 2556), reused 2556 (delta 2556), pack-reused 741
Recibiendo objetos: 100% (3297/3297), 2.05 MiB | 4.76 MiB/s, listo.
Resolviendo deltas: 100% (2822/2822), completado con 1802 objetos locales.
Desde https://github.com/odoo/odoo
* [nueva rama] 10.0 -> upstream/10.0
* [nueva rama] 11.0 -> upstream/11.0
* [nueva rama] 12.0 -> upstream/12.0
* [nueva rama] 13.0 -> upstream/13.0
* [nueva rama] 5.0 -> upstream/5.0
* [nueva rama] 6.0 -> upstream/6.0
* [nueva rama] 6.1 -> upstream/6.1
* [nueva rama] 7.0 -> upstream/7.0
* [nueva rama] 8.0 -> upstream/8.0
* [nueva rama] 9.0 -> upstream/9.0
* [nueva rama] master -> upstream/master
* [nueva rama] saas-1 -> upstream/saas-1
* [nueva rama] saas-10 -> upstream/saas-10
* [nueva rama] saas-11 -> upstream/saas-11
* [nueva rama] saas-11.1 -> upstream/saas-11.1
* [nueva rama] saas-11.2 -> upstream/saas-11.2
* [nueva rama] saas-11.3 -> upstream/saas-11.3
* [nueva rama] saas-11.4 -> upstream/saas-11.4
* [nueva rama] saas-11.5 -> upstream/saas-11.5
* [nueva rama] saas-12 -> upstream/saas-12
* [nueva rama] saas-12.1 -> upstream/saas-12.1
* [nueva rama] saas-12.2 -> upstream/saas-12.2
* [nueva rama] saas-12.3 -> upstream/saas-12.3
* [nueva rama] saas-12.4 -> upstream/saas-12.4
* [nueva rama] saas-12.5 -> upstream/saas-12.5
* [nueva rama] saas-13 -> upstream/saas-13
* [nueva rama] saas-13.1 -> upstream/saas-13.1
* [nueva rama] saas-13.2 -> upstream/saas-13.2
* [nueva rama] saas-13.3 -> upstream/saas-13.3
* [nueva rama] saas-14 -> upstream/saas-14
* [nueva rama] saas-15 -> upstream/saas-15
* [nueva rama] saas-16 -> upstream/saas-16
* [nueva rama] saas-17 -> upstream/saas-17
* [nueva rama] saas-18 -> upstream/saas-18
* [nueva rama] saas-2 -> upstream/saas-2
* [nueva rama] saas-3 -> upstream/saas-3
* [nueva rama] saas-4 -> upstream/saas-4
* [nueva rama] saas-5 -> upstream/saas-5
* [nueva rama] saas-6 -> upstream/saas-6
* [nueva rama] saas-7 -> upstream/saas-7
* [nueva rama] saas-8 -> upstream/saas-8
* [nueva rama] saas-9 -> upstream/saas-9
* [nueva rama] staging.10.0 -> upstream/staging.10.0
* [nueva rama] staging.11.0 -> upstream/staging.11.0
* [nueva rama] staging.12.0 -> upstream/staging.12.0
* [nueva rama] staging.13.0 -> upstream/staging.13.0
* [nueva rama] staging.master -> upstream/staging.master
* [nueva rama] staging.saas-11.3 -> upstream/staging.saas-11.3
* [nueva rama] staging.saas-12.1 -> upstream/staging.saas-12.1
* [nueva rama] staging.saas-12.2 -> upstream/staging.saas-12.2
* [nueva rama] staging.saas-12.3 -> upstream/staging.saas-12.3
* [nueva rama] staging.saas-12.4 -> upstream/staging.saas-12.4
* [nueva rama] staging.saas-12.5 -> upstream/staging.saas-12.5
* [nueva rama] staging.saas-13.1 -> upstream/staging.saas-13.1
* [nueva rama] staging.saas-13.2 -> upstream/staging.saas-13.2
* [nueva rama] staging.saas-13.3 -> upstream/staging.saas-13.3
* [nueva rama] tmp.10.0 -> upstream/tmp.10.0
* [nueva rama] tmp.11.0 -> upstream/tmp.11.0
* [nueva rama] tmp.12.0 -> upstream/tmp.12.0
* [nueva rama] tmp.13.0 -> upstream/tmp.13.0
* [nueva rama] tmp.master -> upstream/tmp.master
* [nueva rama] tmp.saas-11.3 -> upstream/tmp.saas-11.3
* [nueva rama] tmp.saas-12.1 -> upstream/tmp.saas-12.1
* [nueva rama] tmp.saas-12.2 -> upstream/tmp.saas-12.2
* [nueva rama] tmp.saas-12.3 -> upstream/tmp.saas-12.3
* [nueva rama] tmp.saas-12.4 -> upstream/tmp.saas-12.4
* [nueva rama] tmp.saas-12.5 -> upstream/tmp.saas-12.5
* [nueva rama] tmp.saas-13.1 -> upstream/tmp.saas-13.1
* [nueva rama] tmp.saas-13.2 -> upstream/tmp.saas-13.2
* [nueva rama] tmp.saas-13.3 -> upstream/tmp.saas-13.3
Well it doesn't matter, all these changes were the changes they made on their last commit.
git status again to check my repo is updated with the next output
$ git status
En la rama 13.0
Tu rama está actualizada con 'origin/13.0'.
git branch to check I'm in the correct branch.
$ git branch
* 13.0
Ok I'm in the correct branch
Now commes the tricky part.
$ git rebase upstream/13.0
En primer lugar, rebobinando HEAD para después reproducir tus cambios encima de ésta...
Aplicando: Modificando la moneda oficial de Ecuador de sucre a dolar.
Aplicando: introducing Ecuadorian states
Both Aplicando are the names of the commits I made for the pull request that are in my forked repo.
Now if I use git status I got the next result
$ git status
En la rama 13.0
Tu rama y 'origin/13.0' han divergido,
y tienen 3 y 2 commits diferentes cada una respectivamente.
(usa "git pull" para fusionar la rama remota en la tuya)
nada para hacer commit, el árbol de trabajo esta limpio
I dont understand the message of the divergence. What is git trying to tell me with this divergence?? It not suppose to mean that rama 13.0 and origin/13.0 are the same branch??
If I run git log the following result appear:
git log
commit 2aabc340fce82011c864b1ca0b5040add49d6ecd (HEAD -> 13.0)
Author: Osiris Roman <osirisr1994@gmail.com>
Date: Fri May 1 14:08:45 2020 -0500
introducing Ecuadorian states
commit b1d38ab75af5203369f2b8917719623ff2db3e6c
Author: Osiris Roman <osirisr1994@gmail.com>
Date: Thu Apr 30 23:47:39 2020 -0500
Modificando la moneda oficial de Ecuador de sucre a dolar.
La moneda oficial del Ecuador cambió de sucre a dolar en el año 2000.
commit a164b01c1dd9d8612f89b36ad11002d67fca536f (upstream/13.0)
Author: Odoo Translation Bot <c3p@odoo.com>
Date: Sun May 3 01:19:46 2020 +0200
[I18N] Update translation terms from Transifex
commit cc47c76ee70ea684ab8352c47d1d06e7d8282b1b (upstream/tmp.13.0)
Author: std-odoo <std@odoo.com>
Date: Wed Apr 22 09:15:44 2020 +0000
[FIX] mass_mailing: escape the mailing list name
Task-2241443
closes odoo/odoo#50488
X-original-commit: afa2153a24d495b863cd85febca3f96551d8cd56
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
.
.
.
.
.
The first two commits are the ones from the pull request that are supposed to be in my forked repo in github.
The third one is the one that I fetched from the original repo that I want to upload to my forked commit
Git suggest me to make git pull to join remote repo with my local one as I understand.
but if I make git pull then four unpushed commits appear when I run git status and I don't understand why and where these comme from??
Does some one know how to solve this problem??
回答1:
I solved the problem making
git push origin 13.0 --force
The rebase command change the history of the repository. Commits will change hash and lose the ancestry nodes. Then it is neccessary to make push --force to replace the server history with your current one.
Push force is only risky when there is more than one person with the same branch checkout. Other than this, should be ok.
来源:https://stackoverflow.com/questions/61584615/how-to-update-a-forked-repo-that-has-an-unaccepted-pulled-request-of-some-commit