Skip to main content

General Q&A related to Git and GitHub

Q1: What is the difference between Forking and Cloning on GitHub?

Answer:
 # When you say you are Forking a repository you are basically creating a copy of the repository under your GitHub ID. The main point to note here is that any changes made to the original repository will be reflected back to your forked repositories(you need to fetch and rebase). However, if you make any changes to your forked repository you will have to explicitly create a pull request to the original repository. If your pull request is approved by the administrator of the original repository, then your changes will be committed/merged with the existing original code-base. Until then, your changes will be reflected only in the copy you forked.

In short:

The Fork & Pull Model lets anyone fork an existing repository and push changes to their personal fork without requiring access be granted to the source repository. The changes must then be pulled into the source repository by the project maintainer.

Note that after forking you can clone your repository (the one under your name) locally on your machine. Make changes in it and push it to your forked repository. However, to reflect your changes in the original repository your pull request must be approved.

 # In a nutshell, Forking is perhaps the same as "cloning under your GitHub ID/profile". A fork is anytime better than a clone, with a few exceptions, obviously. The forked repository is always being monitored/compared with the original repository unlike a cloned repository. That enables you to track the changes, initiate pull requests and also manually sync the changes made in the original repository with your forked one.

 * Forked project is on your online repository (repo).
 * Cloned project is on your local machine (I usually clone after forking the repo).
You can commit on your online repo (or commit on your local repo and then push to your online repo), then send pull request.

Project manager can accept it to get your changes in his main online version.

https://guides.github.com/activities/forking/
https://help.github.com/articles/fork-a-repo/
https://www.quora.com/What-is-the-difference-between-Git-Clone-and-Fork






Comments

Popular posts from this blog

Git Branching- Learn how to manage multiple versions of a project with Branching.

Git Branch: Up to this point, you've worked in a single Git branch called  master . Git allows us to create  branches  to experiment with versions of a project. Imagine you want to create version of a story with a happy ending. You can create a new branch and make the happy ending changes to that branch only. It will have no effect on the  master branch until you're ready to merge the happy ending to the master branch. In this lesson, we'll be using Git branching to develop multiple versions of a resumé. You can use the command below to answer the question: “which branch am I on?” Command : git branch Check what branch you are currently on.  In the output, the * (asterisk) is showing you what branch you’re on. The diagram above illustrates branching. 1. The circles are commits, and together form the Git project's commit history. 2. New Branch  is a different  version  of the Git project. It contains commits...

Basic Git Workflow- how it's work

Basic Git Workflow: Git is a software that allows you to keep track of changes made to a project over time. Git works by recording the changes you make to a project, storing those changes, then allowing you to reference them as needed. Turning a directory into a project>>  command: git init The word  init  means  initialize . The command sets up all the tools Git needs to begin tracking changes made to the project. Output: would be like-  Initalized an empty g it repository in /home/ccuser/workspace/sorcerers-code/.git/ By the above output, we could say that  The Git project was created. Git workflow: A Git project can be thought of as having three parts: 1. A  Working Directory : where you'll be doing all the work: creating, editing, deleting and organizing files 2. A  Staging Area : where you'll list changes you make to the working directory 3. A  Repository : where Git permanently stores those chan...

How to Backtrack- Learn different ways to undo changes made to a Git project and when to use them.

Head commit : In Git, the commit you are currently on is known as the  HEAD commit. In many cases, the most recently made commit is the HEAD  commit. To see the  HEAD  commit, enter: git show HEAD The output of this command will display everything the  git log command  displays for the  HEAD  commit, plus all the file changes that were committed. For example:  Enter the command to show the  HEAD   commit. Notice the output. The ghost's most recently added line is in green text. Git Checkout: What if you decide to change the ghost's line in the working directory, but then decide you wanted to discard that change? You  could  rewrite the line how it was originally, but what if you forgot the exact wording? The command git checkout HEAD filename will restore the file in your working directory to look exactly as it did when you last made a c...