Before starting with git and github:
open the terminal and try out some basic commands: try to locate where you are, create a file, rename it and move it to another folder.
some basic commands: help pwd cd cd filename example: cd Desktop ls open . cd .. git log ...
- two ways to install git:
- Go to git-scm/download and download the packade you need for your OS
- Open terminal and use following commands: sudo apt-get update sudo apt-get upgrade sudo apt-get install git
Sudo apt
- check if git is installed on your computer by using the command: git git --version
- SSH key <!--- this will store pasword of github so you dont have to do it every time you want to push, pull,...---> open terminal and use following command to generate a ssh key: ssh-keygen -t rsa -b 4096 -C "[email protected]"
copy the key you generate and paste it on your github account. there are two ways to copy: - ctrl+C or cmnd+C - use following command on terminal: pbcopy < ~/.ssh/id_rsa.pub
you need a repository to use git. A repository is a folder in your local computer. On github you also work with repositories.
-
got to your github account and create a new empty repository you can choose to create a readme.md file with it. When you create the repository you create a URL. it can be http or shh.
-
copy the URL link
-
open terminal and use command: git clone (add url you want to clone)
-
command open .
-
Make a change in the readme file and save>
-
command git status if you made changes on git and hit save you still need to add and commit it. Use git commit -a -m "message"
when you commit for the first time, the terminal will ask you who you are. Use following commands:
git config --global user.name "your name" git config --global user.email "email adress"
if you want to check if it worked
git config --list
if you type git status it will make the commit
once you commit changes on your local files. you will want to have the same changes to your github repository. use following commands:
git push git remote git remo -v git push origin master
now we create a repository on the local computer. create a folder woth your documents.
command cd (directory you want to want to turn into repository ) git init git status
git add (filename or folder) git commit -m "#" git status
if we want to push to github: go to github and create a new empty repository (no readme file) command git remote add origin ( you dont have to call it origin) 'url of github repository'
now if you: git push origin master