Git

Manually Create a Git Fork

In Git, forking a repository means creating or making a copy of someone’s remote repository in your GitHub account or in the local system. It is usually used in collaborative software development projects to allow users to work and collaborate on various features or bug fixes without affecting the original codebase. Moreover, you can fork any GitHub repository, make changes to it, and then create or submit a pull request to merge your modifications into the original remote repository.

This article will demonstrate the method of creating a Git fork manually.

How to Manually Create a Git Fork?

To manually create a fork in Git, look at the following steps:

  • Open GitHub and redirect to the target repository that requires to be forked.
  • Click on the “Fork” button.
  • Create a fork by hitting the “Create fork” button.
  • Copy the HTTP URL of the forked repository.
  • Navigate to the local repository and clone the forked repository in it.
  • Add remote origin.
  • Pull changes from the forked repository.
  • Verify changes.

Step 1: Navigate to Target Repository

First, open GitHub and redirect to the target repository that is supposed to be forked. For instance, we want to fork the “Nawzil.com” repository.

Step 2: Create Fork

Then, click on the “Fork” button to create a copy of the target repository into your GitHub account:

After that, change the repository name and description if needed. Next, hit the “Create fork” button:

Upon doing so, the target remote repository will be forked successfully.

Step 3: Copy HTTP URL of Forked Repository

On the newly forked repository, click on the “Code” button and copy its HTTP URL:

Step 4: Clone Repository

Now, create a copy of the forked remote repository into the local system using the below-listed command:

git clone https://github.com/<username>/<forked-repo>.git

Make sure to replace the “username” with your GitHub username and “forked-repo” with the target repository name that needs to be cloned.

Here, our GitHub username is “laibayounas” and we want to clone the “Nawzil.com” repository:

Step 5: Add Remote Origin

Utilize the “git remote add” command and specify the remote name and forked remote repository URL to link the local repository with the forked repository:

git remote add origin https://github.com/laibayounas/Nawzil.com.git

Step 6: Pull Changes

Next, pull the changes of the forked repository into the local repository:

git pull origin master

Step 7: Verify Changes

Lastly, view the Git log to ensure changes:

git log --oneline

In the below screenshot, the content/changes of the target forked repository can be seen:

That was all about manually creating a fork in Git.

Conclusion

To manually create a fork in Git, first, open the GitHub account and switch to the target repository that needs to be forked. Then, choose the “Fork” option and create a fork by clicking the “Create fork” button. After that, navigate to the local repository and clone the forked repository in it. Lastly, pull changes from the forked repository. This article demonstrated the method to create a Git fork manually.

About the author

Laiba Younas

I have done bachelors in Computer Science. Being passionate about learning new technologies, I am interested in exploring different programming languages and sharing my experience with the world.