Git and Github

Git Branch and Fork Differences explained

Posted On
Posted By admin

In this article, we will learn about the differences between git fork and branch. To learn about some Git terms you can refer to this blog post.

What is a Git branch?

A branch represents a line of development. Often, developers use different branches for production releases, bug fixes, etc. Having code in different branches enables developers to make changes to code without messing up the main line of development.

What is a Git fork?

Forking is the process of copying someone else’s repository into your own account. So, when you fork a repository, a copy of the entire repository is available in your own account. Forking is typically used when developers want to make changes to someone else’s repository for their own purpose. Forking does not in any way affect the original repository. Developers can however submit their changes to the project owner by creating a pull request.

Differences between a branch and a fork

The following table lists the differences between a branch and a fork:

BranchFork
A branch is typically created while adding a new feature to your projectA fork is typically created while making changes/contributing to a different user's Github repo.
A branch is temporary, once the feature development is complete, branches are typically merged into main/masterA fork is a distinct identity, it may or may not be integrated with the original repo
A branch is created from your own repositoryA fork is created from a different Github owner's repository
A branch is a Git concept, so there is a git command (git branch) to create a branch.Is a Github concept, so, there is no git command to create by a fork.
A branch can be created via the command (using the git branch command) or via Github by clicking the "create branch" button A fork can only be created by visiting the Github page of the repository that you want to fork and clicking the "fork" button

Further Learning

Conclusion

So, in this article, we learned about git branches and forks and understood the difference between a git branch and a fork.

If you like this post, please do let me know via the comments box below.  You can also connect with me via my Facebook Page or subscribe to my Youtube channel!

Related Post