-1

Forking on Github or Bitcket creates a repo's copy under your own account.

Does this mean that forking is a server-side action? I was unable to find "fork command" inside Git.

If it's not a server-side action, what are the steps to fork a local Git repository with full history and tags?

sandalone
  • 41,141
  • 63
  • 222
  • 338
  • 2
    A fork isn't related to git or any software repository tool: http://en.wikipedia.org/wiki/Fork_%28software_development%29 . In essence, forking means that you start with a copy of a software and start developing independent from the developer who developed the original software. So to answer your question, you can "fork" a repository by cloning it and start developing on your own. – Dirk Trilsbeek Feb 21 '15 at 19:22

4 Answers4

6

Forking is not a technical operation but a process which happens in software development:

[...] a project fork happens when developers take a copy of source code from one software package and start independent development on it, creating a distinct and separate piece of software.

source: http://en.wikipedia.org/wiki/Fork_%28software_development%29

Therefore, strictly speaking there isn't the notion of forking in git. That said, in order to fork a project that's in a Git repository, you have to git-clone it.

Agis
  • 32,639
  • 3
  • 73
  • 81
  • So to "fork" in a way we are used to, we are bound to use Github or Bitbucket or similar Git online services? – sandalone Feb 21 '15 at 19:32
2

Forking is just copying the whole repo. git clone is how you do it locally. Or you could literally just copy the entire repo.

See also Are git forks actually git clones?

Community
  • 1
  • 1
Joel Spolsky
  • 33,372
  • 17
  • 89
  • 105
2

The representation of Fork in Github is a git configuration with some server side logics for Pull Requests features.

Commands to simulate a github fork in git commands:

git clone externalrepo

git remote rename origin external

create a empty repositories (could be any server, but when you use github fork is create in your account)

git remote add origin yourownrepo

git push origin

This is the basic git commands to simulate a fork, and yes a fork live in a server because a git only local is useless.

The extra feature from github is know that your repo is a fork of the original repo to automatically make pull request easy.

Extra information

One pull request is only a notification to original repository to see a specific branch on your repo and integrate:

You can simulate a pull request acceptance with the next git commands:

git add remote pr11111 yourownrepo

git checkout originalbranch //to be integrated

git pull pr11111 yourbranch //the branch requested to pull

git merge pr11111 yourbranch

Community
  • 1
  • 1
Jesús Quintana
  • 1,803
  • 13
  • 18
0

There is a great summary of forking on GitHub, but essentially you are creating a copy of their repo so you can make your own changes to it without affecting the source repo.

This means you can build upon what someone else has done but alter it to your own ends.