How to share git branches that are based on same repository?

感情迁移 提交于 2019-12-06 15:12:33

There are many ways to do this, github recommends pull requests and unless you have no push access to the repository you will need to do this or send patches. There is an example of such a workflow here

git clone git@github.com:<their repo> [optional folder name]
cd reponame (or optional folder name)

If the repository has submodules then

git submodule update --init (if the repo has submodules)
git submodule foreach 'git checkout <their working branch>'

Fork the code. Fork the specific repository you plan to work on. This will give you your own copy of the project. Set up git in the repository you plan to work on.

cd <repo dir or optional one chosen)
git remote set-url origin git@github.com:<your github name>/<your repo>.git
git remote add --track next upstream git://github.com/<their github name>/<their repo>.git

That is your repository set up to help with code. You can do git pull, git push, etc. (this will be to/from your fork). To pull in changes from a branch of the partner repo, just do:

git pull upstream branch

You will not be able to git push to their repo, for that you need to do a pull request.

When you are happy then go to github (your project) and select diff and pull request. This allows you to put in a message and the lib maintainer will get a message to attend to the request. It will also show if your pull request will merge cleanly, it is unlikely to be accepted if the maintainer has to fix code.

Recommended approach in your case is collaborating with your friend.

Here is how:

Add a collaborator

Read this: Will give you basics of git and how to collaborate with others.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!