Intro to Git
Link to Slides
http://tinyurl.com/5zn2xfad
➡️ ➡️ ➡️
⬅️ ⬅️ ⬅️
README: http://tinyurl.com/into-to-git-README
Introduction ❤️🔥
README: http://tinyurl.com/into-to-git-README
What is Git?
Git is a Distribution Version Control System (VCS)
README: http://tinyurl.com/into-to-git-README
What is Git? 🤔🤔🤔
What does VCS really mean… 🤨🤨🤨
Think of Git like a Google Doc:
README: http://tinyurl.com/into-to-git-README
What is Git?
Git works in a similar way to Google Docs, but in a more structured format
Git allows …
README: http://tinyurl.com/into-to-git-README
Benefits of Git
💜
Hack
Git
README: http://tinyurl.com/into-to-git-README
Installation + Configuration✌️
README: http://tinyurl.com/into-to-git-README
Installing Git (Linux or Windows)
** commands that start with “$” are meant to be run on the terminal (cmd for windows). Ignore the “$” when actually running the command **
README: http://tinyurl.com/into-to-git-README
Installing Git (Mac)
Step 1: Install Homebrew Package Manager
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Step 2: Install Git using Homebrew
$ brew install git
** commands that start with “$” are meant to be run on the terminal (cmd for windows). Ignore the “$” when actually running the command **
Homebrew simplifies the process of installing software on Mac by automating the download, installation, and configuration of packages
README: http://tinyurl.com/into-to-git-README
Configuring Git
Git asks for information about you so others know who is doing what changes on a coding project. Configuring Git is the process to telling Git the information needed to collaborate with others on projects.
Commands to Paste:
$ git config --global user.name “John Doe”
$ git config --global user.email johndoe@example.com
“git config” sets Gits options with user information and default behavior
README: http://tinyurl.com/into-to-git-README
Demo 👩🏻💻
Time to install and configure git!
README: http://tinyurl.com/into-to-git-README
Git vs. GitHub 😯🤟
README: http://tinyurl.com/into-to-git-README
Git vs. GitHub → they are different! 🙅🏻♀️🙅🏻♀️🙅🏻♀️
Git:
A version control system that manages and keeps track of code history.
GitHub:
A platform hosted on the web that creates online Git repositories to save code history and shares it with other developers. GitHub provides additional features on top of Git that ease the process of collaborating with others
README: http://tinyurl.com/into-to-git-README
Git Workflow
README: http://tinyurl.com/into-to-git-README
Git: Three Main States
README: http://tinyurl.com/into-to-git-README
Working Directory
How does this relate to git?
← Jim is on his working directory
README: http://tinyurl.com/into-to-git-README
Staging Area
README: http://tinyurl.com/into-to-git-README
Repository (Repo)
README: http://tinyurl.com/into-to-git-README
Repo Visual
⬅️ version 2 has an additional 2 files, files 4 and 5, but is stored in the same area as version 1
README: http://tinyurl.com/into-to-git-README
Local vs. Remote Repository
Local:
Remote:
Vs.
README: http://tinyurl.com/into-to-git-README
Review of the 3 Main States
README: http://tinyurl.com/into-to-git-README
Terminology 🏃🏻♀️
Now that git is installed, what do all these words mean?
README: http://tinyurl.com/into-to-git-README
Clone
🦖🦖🦖🦖🦖🦖🦖
README: http://tinyurl.com/into-to-git-README
Branch
Visualization of branching ⬇️⬇️⬇️
README: http://tinyurl.com/into-to-git-README
Branch Visual
A branch is useful to fix an issue in code and to make new features for a project.
These changes will not be seen on the main branch until they are merged together, where the red circles are (will go over soon)
README: http://tinyurl.com/into-to-git-README
Commit
README: http://tinyurl.com/into-to-git-README
Push
To do this we “push” the commits from a local branch to the remote repository 🥸
README: http://tinyurl.com/into-to-git-README
Push Example
Once you use the command to push your changes, the following screen will populate. Follow the link to make your pull request on GitHub!
README: http://tinyurl.com/into-to-git-README
Pull Request (PR)
👉👈
README: http://tinyurl.com/into-to-git-README
Pull Request Example
You will write a ⬆️
more descriptive explanation of what changes were made
README: http://tinyurl.com/into-to-git-README
Merge
README: http://tinyurl.com/into-to-git-README
Merge Visual
README: http://tinyurl.com/into-to-git-README
Merge Example
Press the green ➡️
“Merge Pull Request” button to merge !
README: http://tinyurl.com/into-to-git-README
Merge Conflict Example
If there is a merge conflict, this box will appear instead of the previous slide. Click the “Resolve conflicts” box.
GitHub will highlight where the conflict is.
You can then fix the conflict on GitHub!
*Note GitHub may not allow you to resolve the conflict on GitHub if the issue is too complex
README: http://tinyurl.com/into-to-git-README
Pull
*Git pull –force forces the local branch to update the remote repos changes, even if it conflicts or overwrites local changes
README: http://tinyurl.com/into-to-git-README
Git Walkthrough
README: http://tinyurl.com/into-to-git-README
Check that Git is installed
Type the following command to verify that Git is installed:
$ git --version
README: http://tinyurl.com/into-to-git-README
Create a Repository
Initializing the repo in your folder is now in the working directory!
README: http://tinyurl.com/into-to-git-README
Create the “main” branch
⬅️ these commands creates this main branch!!!
Make sure to type all 3 commands!!!
README: http://tinyurl.com/into-to-git-README
Demo 👯♀️
Time to create our first repository and initialize the main branch!
README: http://tinyurl.com/into-to-git-README
Overview of Branches
Feature1
Main
Feature2
README: http://tinyurl.com/into-to-git-README
Make Additional Branches
$ git checkout -b “branch name” (creates a new branch and switches to it)
(2) Make changes to your project on this branch
(3) Stage/commit/push changes
$ git add .
$ git commit -m “message”
$ git push -u origin new-branch-name
** repeat these steps as many times as needed to work on additional branches **
When you “git add” you are adding changes made from the working directory since the last commit to the staging area
→ everything you want to add to the staging area
README: http://tinyurl.com/into-to-git-README
Review Branch Commands
$ git checkout - b “branch name”
➡️ creates a new branch [branch name] and switches you to that branch
$ git checkout “branch name”
➡️ switches you to the branch [branch name]
** [branch name] is a placeholder for the actual branch name **
Example: ‘git check -b gitWorkshop’ creates a branch named ‘gitWorkshop’ and switches to ‘gitWorkshop’
README: http://tinyurl.com/into-to-git-README
Push Branches 🧍🏻♀️ ➡️ ➡️ ➡️ ➡️ 🪨
This will populate ⬇️
README: http://tinyurl.com/into-to-git-README
Merge Branches
💭
🧍🏻♀️
When there are merge conflicts
README: http://tinyurl.com/into-to-git-README
Git Workflow: Review 🙋🏻♀️🙋🏻♀️🙋🏻♀️
README: http://tinyurl.com/into-to-git-README
Demo 😎
Now let’s make a new branch, make some changes, and then merge it back into main (uh oh merge conflict 😯)
README: http://tinyurl.com/into-to-git-README
Review of command steps
README: [Link]
Review of fundamental git commands
$ git status ➡️ show changes made since the last commit
$ git init ➡️ create a repository in current file path
$ git checkout -b “[name]” ➡️ create and switch to a new branch
$ git checkout “[name]” ➡️ switch to an existing branch
$ git add . ➡️ add current changes to the next commit
$ git commit -m “[message]” ➡️ commit changes
$ git push -u origin [branch name] ➡️ push changes to remote repo
$ git pull ➡️ integrate changes from remote repo to local branch
README: http://tinyurl.com/into-to-git-README
Thank you for watching!! ❤️❤️❤️
If you have any question before HOTH XI please ask the discord channel!
README: http://tinyurl.com/into-to-git-README