How to push a branch on my fork to someone else's fork

So I have a fork say my-acc/project, and one of my colleague has a fork his-acc/project.

Im working on a branch my-branch on my fork, I want to push this branch to my colleagues’ fork.

If master on both the fork are in sync, how can I achieve this?

A direct push is only possible if your colleague gives you write access to their fork. In that case you can add their fork as a remote of your local repository, and push as usual. For example:

git remote add colleague-fork https://github.com/their-acc/project
git push colleague-fork my-branch

collegue-fork is just a local name for the remote, see also: Git - Working with Remotes

Without write access you can either send your colleague a pull request through GitHub, or let them know which branch they should pull (e.g. via mail or chat). That is usually the better approach, because everyone only writes to their own fork.

1 Like