git

What is a branch? What is a fork

Branching and forking provide two ways of diverging from the main code line. Both Mercurial and Git have the concept of branches at the local level. A repository code branch, like a branch of a tree, remains part of the original repository.  The code that is branched (main trunk) and the branch know and rely on each other. Like a tree trunk’s branch, a code branch knows about the trunk (original code base) it originated from.

Fork is another way of saying clone or copy. The term fork (in programming) derives from an Unix system call that created a copy of an existing process. So unlike a branch, a fork is independent from the original repository. If the original repository is deleted, the fork remains. If you fork a repository you get that repository and all of its branches.
As DVCS hosting evolved, the term fork evolved. The Bitbucket software adds management to forks; forking a repository in Bitbucket has functionality you normally wouldn’t associate with a simple DVCS clone. For example, on Bitbucket, you can always see which repository the fork came from. This isn’t the case with a DVCS clone on your local system.

A comparison of branching and forking

Whether you use either branching or forking, and to what extent, depends on your working environment. There are lots of ways a team can work with and combine fork and branch functionality. Generally, for hosted systems, forks work well in situations where, as a repository admin:

  • You don’t want to manage user access on your repository.
  • You want fine-grain control over merging.
  • You expressly want to support independent branches.
  • You want to discard experiments and changes easily.

The Bitbucket team recommends branching for development teams on Bitbucket; We use a modified form of Vincent Driessen’s GitFlow technique.  Bitbucket branches are useful when:

  • You have a small group of programers who trust each other and are in close communication.
  • You are willing to give the development team write access to a repository.
  • You have a rapid iteration cycle.
Ultimately, though it is your choice – branch or fork – Bitbucket supports both.

Cloning a repository fork or branch

When you want to work on a project by updating its files or adding new files, you need to make a local clone of the remote Bitbucket repository onto your machine or local network. You do this using the Clone button from the Bitbucket repository.  If you forked a repository, you simply clone the fork.  If you branched a repository, you clone the repository and checkout the branch.

Branching

“Branching, in revision control and software configuration management, is the duplication of an object under revision control (such as a source code file, or a directory tree) so that modifications can happen in parallel along both branches.

The originating branch is sometimes called the parent branch, the upstream branch (or simply upstream, especially if the branches are maintained by different organisations or individuals), or the backing stream. Child branches are branches that have a parent; a branch without a parent is referred to as the trunk or the mainline.[1]

In some distributed revision control systems, such as Darcs, there is no distinction made between repositories and branches; in these systems, fetching a copy of a repository is equivalent to branching.

Branching also generally implies the ability to later merge or integrate changes back onto the parent branch. Often the changes are merged back to the trunk, even if this is not the parent branch. A branch not intended to be merged (e.g. because it has been relicensed under an incompatible license by a third party, or it attempts to serve a different purpose) is usually called a fork.”

Setting up .gitignore to ignore unwanted contents at cloud

.gitignore file should be at root of the project with following pattern,

  • Add the file name like project.settings to ignore it
  • If we need to ignore multiple files with same extensions we can use *.settings
  • If we need to ignore multiple files in a directory with same extensions we can use /src/*.xml
  • If we needs to ignore a directory with its all contents, we can use /bin/*

my .gitignore:

/bin/*
/gen/*
/results/*
*.class
*.log
*.png
.project
.classpath
.hg
.settings