withCredentials method using groovy script to use in Jenkins shared library

Can anyone help me how to use the git credentials using a shared library concept in groovy script using withCredentials method and how to call in another shared library groovy file.
or point to a post which is related to this query.