Git Github Presentation
Git Github Presentation
Version control is a method for tracking changes to source code over time in a
way that facilitates collaboration.
GitHub is a platform that hosts git repositories and provides other features and
services built around git.
Why
Whyuse
useversion
versioncontrol,
control,git,
git,and
andGitHub?
GitHub?
Tracking changes
Since version control tracks all changes to your codebase, it allows you to easily
revert your code to a previous state when something breaks.
Collaboration
Version control is built for collaboration. It provides a method for multiple people
to work on the same files in parallel and merge changes together when ready.
Why use version control, git, and GitHub?
It’s free, open source, and scales well from small personal projects to the largest
code bases in the world.
GitHub has become the most popular platform for sharing code and
collaborating on open source projects.
Getting started
Installing Git, using GitHub
Getting started
Optionally add your local SSH key to GitHub so you don’t have to enter your username and password
from the command line all the time: github.com/settings/ssh/new
Then copy the contents of the file in the .ssh directory that ends with .pub to GitHub
Git and GitHub basics
The basic commands you need to know
Creating a new repository
In git, a project / code base is called a repository. To create a new repository, head over to
github.com/new, fill out the details and make sure to check these boxes:
Then hit 👉
$ git pull
Step 2: Make changes, i.e. go about adding, removing, or editing files in the directory of your git repo
$ git add -A
$ git push
More on staging, committing, and pushing
1⃣ First you have to add a snapshot of the files you want to commit to the staging area with
git add. For example:
$ git add -A ← stage all files that have been added, removed, or changed
$ git add -u ← stage only existing files that have changed
$ git add README.md← stage only the README.md file
2⃣ Then you commit them with git commit, which stores the snapshot permanently to your
local repository.
Finally,
3⃣ you ship 📦 that commit off to the remote repository with git push.
Live demo
Collaborate git workflow
Main branch
Step 7: When you’re satisfied with your branch, open a pull request on GitHub
Live demo
Merge Conflicts
Merge Conflicts
Merge Conflicts
Step 1: Merge new branch on master - $ git merge patch-1
Collaboration
Divide work between collaborators.
Each person is responsible for their own file or part of the project.
Create a new branch for each change/addition. Always have a working main.
Communication
Discuss code structure with all collaborators before starting.