Ant A gay nerd
HomeProjectsBlog
Go Back
Blog
Projects
Home

Cheatsheet: Gitlab

Jun 1, 2020
48 seconds

These are the same commands that gitlab shows you when you create a repository. I just posted this post here, because it’s much more convenient to have very quick access to them right here.

Git global setup

git config --global user.name "Yanik Ammann"
git config --global user.email "[email protected]"

Repository Management

Push an existing folder

git init
git remote add origin [email protected]:ConfusedAnt/CHANGE-ME.git
git add .
git commit -m "Initial commit"
git push -u origin master

you may also want to add a .gitignore-file from here;

Push an existing Git repository

git remote rename origin old-origin
git remote add origin [email protected]:ConfusedAnt/CHANGE-ME.git
git push -u origin --all
git push -u origin --tags

SSH-Keys

Run these commands:

ssh-keygen
cat ~/.ssh/id_rsa.pub

And the navigate to gitlab.com/profile/keys and add the SSH-Key.

GPG-Keys

Run these commands to generate and list the key:

gpg --full-gen-key
gpg --list-secret-keys --keyid-format LONG <your-email>
gpg --armor --export <your-key-id> # e.g.30F2B65B9246B6CA

And the navigate to gitlab.com/profile/gpg_keys and add the GPG-Key.

You may also want to set the GPG-Key to be used in every commit.

git config --global commit.gpgsign true

See Also