-
Notifications
You must be signed in to change notification settings - Fork 0
github tutorial Youtube
Youtube Video:
https://www.youtube.com/watch?v=RGOj5yH7evk
git / version control = way to track code changes
repo = folder where the project is kept
git = tool that tracks the changes over time
githib = website where we keep all our repo
- clone -> bring a repo hosted somewhere (for instance on github) into a folder on your local machine
- add -> track your files and changes in git
- commit -> save your files in git
- push -> upload git to a remote repo (like github)
- pull -> download changes from remote repo to local machine
repo = project that contains all my files for a specific project
To create new repo:

Select: README, LICENSE, and .gitignore
(It is recommended that every repository include a README, LICENSE, and .gitignore)
This is a file that describe what the project is about.
You can create the README.md file directly on github or you can create it locally.
create a new repository on the command line
echo "# demo-repo2" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/cecilehannay/demo-repo2.git
git push -u origin main
push an existing repository from the command line
git remote add origin https://github.com/cecilehannay/demo-repo2.git
git branch -M main
git push -u origin main
git clone git@github.com:cecilehannay/github-tutorial.git
cd github-tutorial
The directory github-tutorial contains a file .git that contains all the changes recorded in the history of the repo.
Edit README.md
git status
shows the files that haven't been saved yet in the local repo (it can be files that have been modified
modified:
or files that haven't been saved in the repo)
Untracked files:
git add .
stage the files with git and they are ready to be committed.
git commit -m "Modified the README.md on local repo" -m "Description of the change "
Now the changes is on the local repo
Check what the origin is:
git remote -v
returns
origin git@github.com:cecilehannay/github-tutorial.git (fetch)
origin git@github.com:cecilehannay/github-tutorial.git (push)
git push origin master Origin = the location of our git repo Master = the branch we want to push to
TO avoid to add each time "origin master"
Enter the first time
git push -u origin master
and after
git push
To make a directory a git

We are on the main branch. This is the default branch on the repo. If only one branch, this will be the branch

If we are have several branches, it starts looking like a tree:

Let's say we want to create a new branch called "feature branch" At first the code will be exactly the same on the main branch and the feature branch. But as we make changes on the feature branch, The other branch don't see each other. We want to have a feature branch to make our changes before bringing them back to the main branch.
Very useful, for instance, if we have a bug on the main branch.
We create another branch called the "hot fix branch"

Let's do an example:
Generate a key locally
ssh-keygen -t rsa -b 4096 -C "hannay@ucar.edu"
+> this generates 2 keys private and public