I have two remote: upstream and origin. upstream is something I can't push to. origin is my own repo. How can I fetch all branches from upstream and then push them to origin? I tried:
git fetch upstream git push --all origin
But it doesn't work.
In some cases, you may want to push your changes to another branch on the remote repository. In order to push your branch to another remote branch, use the “git push” command and specify the remote name, the name of your local branch as the name of the remote branch.
No, git push only pushes commits from current local branch to remote branch that you specified in command.
The git push command allows you to send (or push) the commits from your local branch in your local Git repository to the remote repository. To be able to push to your remote repository, you must ensure that all your changes to the local repository are committed.
You may want to try cloning your upstream repo with --mirror
option and then push to your new remote with --mirror
option too
You'll have the following flow:
git clone <upstream-repo-url/repo.git> --mirror cd <repo> git remote add <your-remote-name> <your-remote-url/repo.git> git push <your-remote-name> --mirror
⚠ Be really careful with the push --mirror
as it will delete branches that are on your <your-remote-name>
I just needed to copy one repository from Bitbucket to GitHub, these are the steps assuming your remote is called origin, all branches and tags will be copied:
git remote add neworigin url-to-new-remote git push neworigin --tags "refs/remotes/origin/*:refs/heads/*"
Good thing about this is that files in your working copy won't be modified.
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