Gainst is an old poetic shortening of against. Poets sometimes use it to fit meter, keep a line compact, or create an older or more lyrical tone. It appears mainly in older verse or in poems that deliberately echo older speech.
Example
The cedar leaned gainst the storm-gray sky,
Its roots held fast where the river ran by.