github - Git merge changes between upstream brnches -


i bit unsure how can make changes upstream branch. had local copy of branch a, had commits , pushed origin (my fork). want update branch a on original, , later merge changes branch a branch b on upstream.

fyi, have changes on upstream branch a. want write new changes on top of branch b on upstream.

your question not entirely clear me going assume things. assume want merge commits branch a of local repo branch b of upstream repo. assume fork , upstream repos reside on github (because tagged github).

there many ways this, depending on whether have write access on upstream repo. recommended methods merging on shared repo 2nd , 3rd ones (using pull request workflow)

if have write access upstream repo

  1. in local repo, set upstream repo 1 of remote repo, if haven't (you can name whatever want, people name upstream). command is

    git remote add upstream <url/path of upstream repo>

  2. fetch branch b upstream executing (both, in sequence)

    git fetch upstream

    git checkout upstream/b

    or (if have local copy of b)

    git checkout b

    git pull upstream

  3. merge b a

  4. while @ branch b, execute git push upstream b

note merging other people's branch locally , pushing shared remote repo considered bad practice owner of branch may not realize his/her remote branch modified, may result in branch divergence , unnecessary merges.

if don't have write access upstream repo

this method used people regardless of whether have write access upstream repo or not. i.e. people don't push upstream straight away unless under special circumstances, despite having write access.

  1. push branch a origin (your fork)

  2. go upstream repo on github , submit pull request. (note branches pull request from , merge into)

  3. wait owner/collaborator of remote repo accept pull request.

yet alternative

i noticed mentioned have changes on branch on upstream repo. in case can pull request straight away. , if have write access repo, can accept own pull request straight away. again, bad practice on shared repo, if branch b not owned you, or shared branch.

hope helps.


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -