Git command to checkout latest commit from develop branch

ぃ、小莉子 提交于 2019-12-06 15:35:38

From what I see, following need to happen. Your credential in Jenkins need to be a private key.

Authentication phase:

# optional. check whether the gitLabServer is already trusted
ssh-keygen -F ${gitLabServer} 
# adds the gitLabServer into known_hosts. This stops interactive prompts during git clone.
ssh-keyscan ${gitLabServer} >> ~/.ssh/known_hosts

# Add your existing private key (like id_rsa) into authentication agent
eval `ssh-agent -s`
ssh-add /path/to/key/credential

Git clone phase:

# Finally, clone the repo with branchName as a parameter
git clone -b ${branchName} git@${gitLabServer}:${projectName}/${repo}.git

The command you are looking for is

git checkout branchName

You can use a certificate as explained in this answer

If your repo provider support token based communication as github add token to repo url https://[token here]@github.com/[your name]/[your repo].git See the documentation to know how to provide token.

You also can use something as:

git remote set-url --push origin https://<username>:<password>@github.com/<repo>

But we understand that it's the unsecured way and strongly not recommended to use it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!