简体   繁体   中英

Git push my branch changes to another repository

I am in a Git repository, and in my branch there are some commits. I need to push only this branch's changes into another remote repository. How can I achieve this?

I have tried the command git push git@bitbucket.org:XXX/XXX.git launchpad-issues .

This command pushes the whole repository, but I am looking to just push the changes on one branch only.

You can add another remote to your local git and then push to it. Say you want to push the foo branch

# Add another remote called 'my-other-repo'
git remote add my-other-repo git@bitbucket.org:XXX/XXX.git

# Push the foo branch to my-other-repo
git push my-other-repo foo

And if you want you can optionally remove the remote afterward

git remote remove my-other-repo

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM