Here we have git and sometimes GitHub basics for an idiot
Git configuration
Configuration can be local or global. We'll discuss global config.
Username
shell
git config --global user.name "Cheshi Mantu"shell
git config --global user.email cheshi.mantu@emailserver.serverDefault code editor
We'll use VS Code.
shell
git config --global core.editor codeCheck global config
shell
git config --listGet your RSA public key
See this article to understand what is it and how to generate the RSA key pair.
Provide keys to GH
- On GH side click your avatar in the top right corner an then jump to Settings.
- In the Settings (on the left hand side) find SSH and GPG keys.
- Click new SSH key
- Name the key
- Copy the result of the command
cat ~/.ssh/id_rsa.pub. - Save.
Start working on a GH project
If all work is done on GH side and there are files, then easy-peasy.
- Create GH repo (presumably done).
- Clone the repo.
- Do stuff.
- Update GH repo
Clone repo
shell
# I'm using SSH not HTTPS
git clone git@github.com:cheshi-mantu/www-diary.git
# for HTTPS (really?) usage you need different link.
git clone https://github.com/cheshi-mantu/www-diary.gitDo suff, Update GH repo
You need add all the changes, create a new commit and then push the stuff to the cloud (GH).
shell
# collects all the changes
git add .
# creates commit with comment
git commit -m "describe the stuff done"
# pushes the committed changes to GH
git push originRelinking git project from one remote to another
Check what is the remote.
bash
git remote -vIt will result in summat like
bash
git remote -v
origin git@github.com:cheshi-mantu/www-diary.git (fetch)
origin git@github.com:cheshi-mantu/www-diary.git (push)Now, I want to change the remote to gitlab https://gitlab.com/cheshimantu/www-diary.git`
bash
git remote set-url origin git@gitlab.com/cheshimantu/www-diary.gitThen
bash
git remote -vThen push the stuff to new remote
bash
git push -u origin master