Skip to content

Git setups

Config SSH key

ssh-keygen
cd /home/user/.ssh
cat /home/user/.ssh/id_rsa.pub

copy the whole thing
go to gitlab - settings - profile - ssh keys - add key
add that shit

Git global setup

git config --global user.name "User Name"
git config --global user.email "User@email.com"

Create a new repository

git clone git@gitlab.com:User_Name/project_name.git
cd project_name
git switch --create main
touch README.md
git add README.md
git commit -m "add README"
git push --set-upstream origin main

Push an existing folder

Go to gitlab Click on create repository Choose "blank" and deselect everything Follow the instructions

Push an existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin git@gitlab.com:User_Name/project_name.git
git push --set-upstream origin --all
git push --set-upstream origin --tags

Git maintence

Push to remote

git add .
git commit -am "commit message"
git push origin master

Pull from remote

git pull origin master

Merging branches

Check this

Check branches

git branch

Change branch

git checkout new-branch

Push all branches

git push origin --all

http://git-cheatsheet.com/