Use a "Username with password" credential (note: for GitHub, use a Personal Access Token instead of your password). SSH: Use an "SSH Username with private key" credential.
For a public repository, you only need the URL and the branch name. This is often the first step in a Jenkinsfile. jenkins pipeline download git repository
Argument Descriptions. url : String. URL of the repository to be checked out in the workspace. Required parameter. Repository URL' Use a "Username with password" credential (note: for