Last active
July 16, 2020 01:14
-
-
Save gijun19/8f6756e56ed6b3209574293c227c3f50 to your computer and use it in GitHub Desktop.
GitLab token clone helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PAT="$PAT_OR_TOKEN" | |
export USER="$USER_NAME" | |
function gcpat { | |
substring=$(echo "$1" | sed -e 's/https:\/\///g') | |
url=https://"$USER":"$PAT"@"$substring" | |
git clone "$url" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Overview
This snippet enables a function called
gcpat
which will automatically format a HTTPS GitLab url to its token counterpart.How to use
If you use
zsh
you will need to edit.zshrc
, if you usebash
edit.bashrc
, any others edit the respective configuration file.Just copy and paste the following into the file and replace the
NGK
variables with your values. This could either be an OAuth token or just a regular PAT from GitLab.Then either restart your terminal or use
source ${path/to/bash_config}
.Then you can just grab any HTTPS url from the GitLab UI and call the function from your terminal.