Forking and Branching¶
Forking clones the original repository and creates an independent repository. Branching allows you to develop independently of the main branch based on the changeset branched, but remains linked to the main repository.
Both provide excellent collaboration functionality, and do not differ greatly, but you can find many online discussions where people fight about the differences.
Fork a repository¶
To fork a repository, use the following steps:
- Select the repository you wish to fork.
- On the Create fork page, set the following properties:
- The fork name
- The fork description
- If the fork is private or public
- The copy permissions
Branch a Git repository¶
Currently branching is only supported from the command line but is picked up on the web interface. To branch a Git repository use the following example:
# branch and checkout git branch new-branch git checkout new-branch # same function shorthand git checkout -b new-branch # Example usage $ git checkout -b example-branch Switched to a new branch 'example-branch' $ git status On branch example-branch Initial commit nothing to commit (create/copy files and use "git add" to track) $ vi example-script.sh $ git add example-script.sh $ git commit -a -m "ghost script: initial file" $ git push
Once it is pushed to the RhodeCode Enterprise server, you can switch to the newly created branch using the following steps:
- Select .
- Select the repository you branched.
- Select and choose the new branch.
For more information, your can read more here on the Git website, Git Branching.
Branch a Mercurial repository¶
To use branches in Mercurial like Git, use the hg bookmark option instead. Also see the Mercurial Branching Vs Bookmarking section for more information.
To branch a Mercurial repository, use the following example and push your changes to the main repository. Once pushed, you can view the new branch in RhodeCode Enterprise by selectingfrom the repository page.
$ hg branch example-456 $ hg ci -m "branch: ticket #456" $ hg push --new-branch