I am using a fork of a fork. I will denote these fork1 and fork2. I work on fork2.
project(upstream) --> fork1 --> fork2(origin) --> local
Parenthesis denote the role ie, project acts as the upstream repo, fork2 is the origin repo, and local is the local repo. A lot of commits have gone into upstream
. I have made many changes to a branch in local which I will call local/branch_new
(I do not use local/master
). I would like to update local/branch_new
to that of upstream/master
while retaining all of my local changes (they will not conflict, they are entirely new, added files, although they depend on files which do have changes to them in the upstream version). Then I will push local/branch_new
to origin(fork2)
and make a pull request
to upstream/master
.
Steps I believe I need to do
project
officially as upstream
. Currently, when I git pull
, it believes origin/branch_old
is the upstream. I am on a different branch and don't want it associated with origin/branch_old
.git pull
to update my local branch or possibly, update local/master
, and then update local/branch_new
?git push
from local/branch_new
to form a new origin/branch_new
. This part should be trivial.I am stuck on parts 1 and 2.
How I will do:
Set the upstream of branch_new to origin:
git branch -u origin/branch_new
Update the local information about upstream:
git fetch upstream
When on branch_new
, stash my local change:
git stash
add some change to commit with git add -p
, then commit git commit
and finally push git push
rebase my local branch:
git rebase upstream/master
Then apply my stashed modification:
git stash apply
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.