Bootstrap FreeKB - Git (Version Control) - fork a repository
Git (Version Control) - fork a repository

Updated:   |  Git (Version Control) articles

A fork is similar to cloning a repository, but also very different.

When you clone a repository, you are creating a copy of the repository on your local system, and changes you make to files in the repository can be pushed to the origin repository, using the git push command.

 

When you fork a repository, you are creating a copy of the repository, owned by you. For example, let's say the foo.git repository is owned by john.doe.

ssh://git@example.com/john.doe/foo.git

 

Different flavors of Git have different ways of forking a repository. There should be some sort of option to create a fork. However, git does not have a command line tool that can be used to create a fork, which is kind of surprising.

 

When you create a fork, you become the owner of the forked repository. In this example, the forked foo.git repository would be owned by the person that created the fork (jane.doe in this example).

 

Optionally, Jane could clone her fork of the foo.git repository to a directory on some other system, such as her personal laptop, and then push updates back into her forked repository. But this isn't required. Jane could just as well edit the files directly in her forked repository.

git clone ssh://git@example.com/jane.doe/foo.git

 

Often, forks are created with the intention of making changes to files in the repository, and then to have the changes merged back into the original source repository. In this scenario, after Jane makes her changes, she may want her changes merged into the source repository owned by John Doe. Jane would make a pull request, requesting that John pull her changes into the original source repository.

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter ce4b62 in the box below so that we can be sure you are a human.