2

I've forked a project on Github. Now I want to contribute to the forked repo as well as develop an in-house application using that same repo.

The in-house application strips off several lines of code that isn't required. In house-app should be managed as a branch, fork or a clone ?

As far as I understood, fork is a github-to-github copy of a repo. Clone is a local copy of a github repo. Not sure what are branches... but adding a branch does not make a new local copy (when git is installed.)

Sachin Jain
  • 21,353
  • 33
  • 103
  • 168
Chirag
  • 1,189
  • 2
  • 21
  • 43

2 Answers2

1

There is a difference between all of the three: fork, clone and branch.

  1. Fork: After you have forked a repo then you are the owner of the forked repo. You can do whatever you want.

  2. Clone: Cloning a repo makes that repo available to you. Remember, you can add multiple remotes after cloning a repo So it depends on you on which remote you are working.

  3. Branch: Branching does not create any new repo. A branch contains a series of commits. Generally branching is used when we work on two(or more) things simultaneously. Like fixing a bug and developing a new feature.

If you want to manage a forked repo independently, you can always do that. As I said, you are the owner of the forked repo now. Just clone the forked repo again at different location and do your things.

Or, get all the code from the forked repo, over-write the existing git history by creating a new repository and push it with another name.

Sachin Jain
  • 21,353
  • 33
  • 103
  • 168
  • hmm I see, any way to confirm that a clone belongs to which branch? – Chirag Feb 19 '14 at 04:22
  • clone belongs to repository not a branch. I mean you clone a repository and you get all the branches in that repository. You can use git branch to checkout on which branch you are working but clone and branch are completely different things. – Sachin Jain Feb 19 '14 at 04:24
  • But we can certainly clone a specific branch as mentioned in my answer. – Chirag Feb 19 '14 at 04:27
  • @Chirag This is equivalent to cloning a repository and checking out different branch. Just a shortcut for 'git clone https://git@github.com/username/myproject.git' AND 'git checkout mybranch' as mentioned in this answer as well http://stackoverflow.com/a/6691222/1310070 – Sachin Jain Feb 19 '14 at 04:35
0

The best way is to make a branch and have a separate clone of master and the branch.

Clone a specific branch using:

git clone -b my-branch https://git@github.com/username/myproject.git

Reference: https://stackoverflow.com/a/4568323/1331135

Community
  • 1
  • 1
Chirag
  • 1,189
  • 2
  • 21
  • 43