Github and Gitlab

Git is a useful tool and is also confusing for many newbies. This tutorial is trying to put a few useful tips

Switching between GitLab and GibHub

Suppose you have a code repository, either on github or gitlab, you want to switch from to another, what you need to do is to change the origin. Here are the steps:

git remote -v

git remote remove origin

git remote add origin https://gitlab-token-name: token@gitlab.com/myuser/myrepo.git 

git branch -M main

git push -uf origin main

If you have several branches and would like to push them all, do the following

git push --all

Git branch

To check the available branches, 

git branch -a

To checkout a branch

git checkout -b my-new-branch

To switch between branches:

git switch new-branch