Replace the source plug completely (github)

Is there a smart workflow for creating a pull_request branch on a fork that diverges from an upstream repo, so that the pull_request branch always perfectly matches the upstream "master"?

I.e

1) I have a plug, which is significantly different from the parent console.

2) I want to keep my plug (it makes no sense to delete it), but I also want to cleanly issue requests for traction, which are minimally at odds with the original repository up.

So - is there a way to create a branch in my fork that is a perfect copy of another remote master?

+7
git pull-request
source share
2 answers

First of all, you should not change the local master branch, you should only create function branches. If you saved your local master unmodified, then you can get the latest changes to the upstream repository:

 git remote add upstream <url-for-upstream-repo> git fetch upstream 

Now your upstream/master remote tracking branch is in sync with the latest changes from upstream . If you wish, you can also update the local master if you want:

 git checkout master git merge upstream/master 

Now you can create upstream/master function branches:

 git checkout -b feature upstream/master 

If you want to synchronize function branches with the latest changes from upstream , you can use rebase if no one is working on the function branch (otherwise you will eventually force them to re-synchronize with the changed history). rebase is actually perfect for this workflow, as you can usually use it to synchronize function branches as often as you want, without creating a messy history because they don't create commit commit:

 git fetch upstream git checkout feature git rebase upstream/master 

You could also git merge upstream/master instead of reloading, but you will leave the merge credit, so over time you will create a more complex history by joining rather than reloading.

When you are ready to send the transfer request, just click on origin and make a request against the upstream master .

The original poster asks:

[I] Is there a way to create a branch in my fork that is a perfect copy of another remote master?

As long as your local master does not diverge from upstream/master (which should not be done if you did your work in function branches and not directly in master ), just click on your local master on origin :

 git push origin master 

Alternatively, you can use refspec to direct the upstream/master remote tracking branch to your origin/master :

 git push origin upstream/master:master 
+13
source share

To completely replace the plug with origin:

 git remote add upstream <upstream_repository_url> git fetch upstream git reset --hard upstream/master 

Got it from here

0
source share

All Articles