Is generativism originated from formalism? How formalism is related to linguistics
By "generativism", I assume you mean "the theory of Generative Grammar". This is a theory promulgated by Chomsky starting, in one form, in 1951. It came to be known as "generative grammar" with the publication of Aspects of the theory of syntax (see chapter 1). The word "generate" is taken from mathematics, with reference to Emily Post's theory of combinatoric systems. His particular construction of "generative grammar" in the 60's is a bit peculiar, because he defines a "grammar" as being an account of a person's mental faculty for understanding and producing sentences – that is, it is necessarily mentalist – and "generate" means to give an completely explicit account of. I am not endorsing this version of the theory, I am simply reporting Chomsky's view.
It's not exactly clear what "formalism" is. Usually people (in general) think of formalism as being a particular level of explicitness where statements can be reduced to a symbolic system, e.g. formulas in symbolic logic. Puting the pieces together, a generative grammar would then be a system of symbolic expressions that is a homolog of what the mind does in creating and producing utterances.
Historically speaking, the formalism comes first. See for example Chomsky's hyper-mathematical MA thesis on Hebrew and Logical structure of linguistic theory. The mentalist interpretation emerged over the next 15 years, when we can say that it clearly "was born" and named "generative" by the time of Aspects. Prior to Chomsky, there were symbolic notational systems for describing language promulgated by various structuralist linguists, which were clearly non- and even anti-mentalist. Subsequently, there are also non-mentalist formal grammatical systems, such as HPSG (the founders inform me that theirs is a non-mentalist theory). Whether or not Chomsky's various theories of grammar are actually and in fact the same as what the mind does is irrelevant, the question is whether "mental reality" is a standard which a given theory is held to. In that sense, there are plenty of mind-agnostic theories of grammar.
Formalism relates loosely to linguistics. Linguists usually thing of what we do as being "science", and therefore we strive to be "scientific" which means "having a standardized system of formalism". The fact is that the formalisms have generally been defective, and we end up including plain English descriptions in our rule (or whatever) systems. This is certainly the case when it comes to low-level primitives like the features and their definitions.