Sometime ago I forked a git repo. Since then there has been several new commits to the master branch. https://help.github.com/articles/syncing-a-fork/ explains how to sync the upstream master branch with the local master branch and then push those commits to my fork.
However it does not mention how to sync new upstream branches. When I originally forked the project on github it looks like it brought over all of the then current branches.
I've seen explanations on how to sync one branch at a time. Is there any way to sync all of the branches new and old all at once?
I haven't made any commits to my fork. Thus I am looking for a fast forward sync.
Edit: Another way to say this:
I want
git ls-remote origin
to match
git ls-remote upstream
This would include branches and tags.
Here are some notes on syncing a fork with the upstream repository. Configure a remote upstream that points to the upstream (original) repository in Git. This is needed to sync changes you make in a fork with the original repository.
You're going to apply changes from upstream to local first, and then push them to origin after that's done. To get the changes from the upstream repo, you need to fetch them (and specify the remote). Now check out your master branch and merge the upstream master into it:
If you are using GitHub for Windows or Mac then now they have a one-click feature to update forks: Select the repository in the UI. Click "Update from user/branch" button the top. Actually, it is possible to create a branch in your fork from any commit of the upstream in the browser:
Before you can sync, you need to add a remote that points to the upstream repository. You may have done this when you originally forked. Tip: Syncing your fork only updates your local copy of the repository; it does not update your repository on GitHub.
However it does not mention how to sync new upstream branches
All you need to do is:
git fetch upstream
It supposes you have a remote repository referenced as upstream
.
If not:
git remote add upstream <upstream_url>
That will fetch or update all the upstream branches and store them in your local repo, in the upstream namespace.
You can see those branches with:
git branch -avv
it it doesn't let me push all of the upstream branches to origin.
For that, you need to make a local branch based on any upstream branch you want to push to origin:
git branch abranch upstream/abranch
gut push -u origin abranch
See more at "git - create local branch from existing remote branch".
To do so for all branches, see "Pull all branches from remote through it's mirror bare remote".
Or, better: "Track all remote git branches as local branches".
Simply use "upstream
" instead of origin
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With