SlideShare uma empresa Scribd logo
1 de 46
Introduction to:               &


Max Claus Nunes
maxcnunes@gmail.com
http://blog.maxcnunes.net
https://github.com/maxcnunes
Version Control Systems
•   Without
•   Local
•   Centralized         What?!

•   Distributed
Without Version Control
            Systems
• Copy files into another directory
• Store or Share files backups by email
• Store or Share files by pendrive
Local Version Control
              Systems
• Just a local
  Database
• Systems:
  – RCS - Revision
    Control System
    (Today is centralized)




                               http://git-scm.com
Centralized Version Control
           Systems
• A Central Server
• The most used for
  the companies
• Systems:
  – CVS
  – Subversion
  – TFS
                         http://git-scm.com
Centralized Version Control
            Systems
Advantages
• Everyone knows to a certain degree what everyone else on the project is
  doing
• Administrators have more control over what everyone can do




Disadvantages
• If Server goes down, this means nobody can save changes
• If HD Server breaks, this means good bye all control version history
Distributed Version Control
           Systems
• Distributed: each client
  has fully mirror of the
  repository
• Systems:
  – Git
  – Mercurial
  – Bazaar


                             http://git-scm.com
Distributed Version Control
            Systems
Advantages
• Everytime someone pulls from the central repository, Git gets a full
  history of the changes
• Most of the functionalities doesn’t need access to some network. So we
  can work even not connected to the internet
• A project can be associated to a more than one remote repository
• You can do anything just using the console


Disadvantages
• Git requires some learning curve to understand its concept
• The administrators don’t have control over what happens on each client
  local repository
A Short History of Git
• (1991-2002) – The Linux kernel changes to the
  software were passed around as patches and
  archived files.
• (2002) – The Linux kernel project began using a
  proprietary DVCS system called BitKeeper.
• (2005) – The relationship between Linux kernel
  and the BitKeeper broke down. After that Linux
  development community create their own tool
  named Git, based on what they learned using the
  BitKeeper.
Some Git Goals
• Speed
• Simple design
• Strong support for non-linear development
  (thousands of parallel branches)
• Fully distributed
• Able to handle large projects like the Linux
  kernel efficiently (speed and data size)
Git Basics
•   Snapshots, Not Differences
•   Nearly Every Operation Is Local
•   Git Has Integrity
•   Git Generally Only Adds Data
•   The Three States
Snapshots, Not Differences




                         http://git-scm.com

           Differences
Snapshots, Not Differences




                       http://git-scm.com

           Snapshots
Nearly Every Operation Is
             Local
• You can work offline as look the history,
  commit some changes or create branchs
Git Has Integrity
• Git generate a SHA-1 hash for each commit
  associated a file
• Git realize a checksum everytime is tried to
  store some change. So Git knows when
  something was changed or the file is
  corrupted

   24b9da6552252987aa493b52f8696cd6d3b00373
Git Generally Only Adds Data
• Doing commits regularly it is very difficult to
  get the system to do anything that is not
  undoable or lose some change
• Let us more comfortable to experiment
  changes, because is easy to recover a previous
  version
The Three States
                              http://git-scm.com




Modified/Untracked   Staged   Committed
Lets start use Git
So, what are we going to do?
• Configure             •   Alias
• Create a Repository •     Diff
• Passing through the 3 •   Tag
  States                •   Ignoring Files and
• Branch                    Folders
• Merge                 •   Getting a Remote
• Log                       Repository
                        •   Basic Workflow
Configure
• Download and Install Git: http://git-scm.com/
• You just need the Git Bash to work
Username

git config --global user.name "Your Name Here"
# Sets the default name for git to use when you commit



Email

git config --global user.email "your_email@example.com"
# Sets the default email for git to use when you commit
Create a Repository

     Access your project directory

    cd your_folder_name

    Create the repository

    git init


    Check the repository current status

    git status




All your repository data and configuration is stored on a hidden folder named   .git on your repository’s root
Passing through the 3 States
                                  How is the status now?

 Create or Change a file/folder               From Nowhere/Repository Working Directory

touch file_name/folder

                                  How is the status now?


 Add objects to staging area                               Working Directory  Staging Area


git add (general_comand/file_name/folder_name/…)


                                  How is the status now?
                                                                 Staging Area  Repository
 Save objects on local repository

git commit –m ‘This is my awesome comment’

                                  How is the status now?
Adding, Removing and Renaming
Stages All
git add -A

Stages new and modified, without deleted
git add .

Stages modified and deleted, without new
git add -u

Stages a removed file
 git rm file_name/

Stages a removed folder
 git rm -r folder_name/

Stages a renamed file
 git mv old_file_name new_file_name
.gitignore
Is a hidden file named .gitignore on your root’s repository that contains a list
of all ignored files and folders, like:
*.tmp
x64/
Diff

Compare the working directory with local repository

git diff HEAD file_name


Compare the working directory with staging area

git diff file_name


Compare the index with local repository

git diff --cached file_name

 Compare the branchs showing just the status and file name

 git diff --name-status branch_1 branch_2
Custom Alias

Create a new alias to show a log with graph

git config --global --add alias.lol "log --graph --
decorate --pretty=oneline --abbrev-commit --all"

Using the new alias

git lol


List all the local configurations

git config –-local -l
Branchs
Create and Switch for a new branch

git checkout –b branch_name

List all local branchs

git branch
Switch for a existing branch

git checkout branch_name

                                             Working with Remote Repositories
Add a local branch for a remote repository

git push remote_name branch_name

Update local branch from a remote branch

git pull remote_name branch_name
Merges
Merge on the current branch changes made on another branch

git merge branch_name

         Before merge




         After merge
Merge Conflicts
                     Master              Development




Merge conflict




                        Resolving the conflict




  Commit the file after resolve the conflict

 git commit –a -m ‘Resolving merge conflicts’
Tags
List all tags

git tag

Creating an annotated tag

git tag -a tag_name -m 'message description'

git tag -a v1.0 -m 'my version 1.0'


                                           Working with Remote Repositories
Sharing tags

git push origin v1.0

All tags

git push origin --tags
Git + Social Coding
Add and Pull a Remote
             Repository
Cloning a or repository

git clone git@github.com:owner_repo/repo_name.git


Actually what the clone command does is: remote add + pull

git remote add origin
git@github.com:owner_repo/repo_name.git

git pull origin master


And actually what the default pull command does is: fetch + merge

Update local repository avoiding the amount of merges (fetch+rebase)
git pull --rebase repo_name branch_name
Pushing to the Remote
             Repository
Pushing for the remote repository

git push remote_name branch_name

git push origin master
Basic
Workflow




           http://nakedstartup.com/2010/04/simple-daily-git-workflow
Others helpful (or not) commands

 List of Git Contributors

 git shortlog -s -n

 Show the SHA1 of a file staged

 git ls-files -s file_name

 Show the SHA1 of a file modified

 git hash-object file_name

 Discard changes of a file

 git checkout --file_name
Others helpful (or not) commands

 Undo git add before commit

 git reset HEAD file_name

 One line logs

 git log --pretty=oneline

 Short status

 git status -s

 Delete the last commit before Push

 git reset --hard HEAD~1
Questions
Look more…
• Using SSH security connections
• Git Cheat Sheet Grey
• http://git-scm.com

Mais conteúdo relacionado

Mais procurados

Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHubVikram SV
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version ControlSourabh Sahu
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & GitCraig Smith
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash CourseNilay Binjola
 
Git 더하기 GitHub(구름IDE 환경)
Git 더하기 GitHub(구름IDE 환경)Git 더하기 GitHub(구름IDE 환경)
Git 더하기 GitHub(구름IDE 환경)Junyoung Lee
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
Understanding Branching and Merging in Git
Understanding Branching and Merging in GitUnderstanding Branching and Merging in Git
Understanding Branching and Merging in Gitgittower
 
Version Control System
Version Control SystemVersion Control System
Version Control Systemguptaanil
 
git, 이해부터 활용까지
git, 이해부터 활용까지git, 이해부터 활용까지
git, 이해부터 활용까지jylee1229
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagramsDilum Navanjana
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlJeremy Coates
 

Mais procurados (20)

Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git training v10
Git training v10Git training v10
Git training v10
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Understanding GIT and Version Control
Understanding GIT and Version ControlUnderstanding GIT and Version Control
Understanding GIT and Version Control
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git 더하기 GitHub(구름IDE 환경)
Git 더하기 GitHub(구름IDE 환경)Git 더하기 GitHub(구름IDE 환경)
Git 더하기 GitHub(구름IDE 환경)
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Git basic
Git basicGit basic
Git basic
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Understanding Branching and Merging in Git
Understanding Branching and Merging in GitUnderstanding Branching and Merging in Git
Understanding Branching and Merging in Git
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Git
GitGit
Git
 
Version Control System
Version Control SystemVersion Control System
Version Control System
 
git, 이해부터 활용까지
git, 이해부터 활용까지git, 이해부터 활용까지
git, 이해부터 활용까지
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Git Pull Requests
Git Pull RequestsGit Pull Requests
Git Pull Requests
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 

Destaque

Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at EclipseChris Aniszczyk
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Building an Email Marketing System
Building an Email Marketing SystemBuilding an Email Marketing System
Building an Email Marketing SystemLiam Dempsey
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version ControlWei-Tsung Su
 
Inside GitHub
Inside GitHubInside GitHub
Inside GitHuberr
 
Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012 Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012 Atlassian
 
11. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:211. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:2Fabio Fumarola
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHubNishan Bose
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for DocumentationAnne Gentle
 

Destaque (13)

What is attentional blink
What is attentional blinkWhat is attentional blink
What is attentional blink
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
 
Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at Eclipse
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Building an Email Marketing System
Building an Email Marketing SystemBuilding an Email Marketing System
Building an Email Marketing System
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
Inside GitHub
Inside GitHubInside GitHub
Inside GitHub
 
Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012 Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012
 
11. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:211. From Hadoop to Spark 1:2
11. From Hadoop to Spark 1:2
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Introduction to GitHub
Introduction to GitHubIntroduction to GitHub
Introduction to GitHub
 
Git and GitHub for Documentation
Git and GitHub for DocumentationGit and GitHub for Documentation
Git and GitHub for Documentation
 

Semelhante a Introduction to Git and Github

Semelhante a Introduction to Git and Github (20)

Git 101
Git 101Git 101
Git 101
 
git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git training (basic)
Git training (basic)Git training (basic)
Git training (basic)
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git introduction
Git introductionGit introduction
Git introduction
 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
 
Git hub
Git hubGit hub
Git hub
 
Git 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using GitGit 101 - Crash Course in Version Control using Git
Git 101 - Crash Course in Version Control using Git
 
Learning git
Learning gitLearning git
Learning git
 
Git basics for beginners
Git basics for beginnersGit basics for beginners
Git basics for beginners
 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 

Introduction to Git and Github

  • 1. Introduction to: & Max Claus Nunes maxcnunes@gmail.com http://blog.maxcnunes.net https://github.com/maxcnunes
  • 2. Version Control Systems • Without • Local • Centralized What?! • Distributed
  • 3. Without Version Control Systems • Copy files into another directory • Store or Share files backups by email • Store or Share files by pendrive
  • 4. Local Version Control Systems • Just a local Database • Systems: – RCS - Revision Control System (Today is centralized) http://git-scm.com
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. Centralized Version Control Systems • A Central Server • The most used for the companies • Systems: – CVS – Subversion – TFS http://git-scm.com
  • 10. Centralized Version Control Systems Advantages • Everyone knows to a certain degree what everyone else on the project is doing • Administrators have more control over what everyone can do Disadvantages • If Server goes down, this means nobody can save changes • If HD Server breaks, this means good bye all control version history
  • 11. Distributed Version Control Systems • Distributed: each client has fully mirror of the repository • Systems: – Git – Mercurial – Bazaar http://git-scm.com
  • 12. Distributed Version Control Systems Advantages • Everytime someone pulls from the central repository, Git gets a full history of the changes • Most of the functionalities doesn’t need access to some network. So we can work even not connected to the internet • A project can be associated to a more than one remote repository • You can do anything just using the console Disadvantages • Git requires some learning curve to understand its concept • The administrators don’t have control over what happens on each client local repository
  • 13.
  • 14. A Short History of Git • (1991-2002) – The Linux kernel changes to the software were passed around as patches and archived files. • (2002) – The Linux kernel project began using a proprietary DVCS system called BitKeeper. • (2005) – The relationship between Linux kernel and the BitKeeper broke down. After that Linux development community create their own tool named Git, based on what they learned using the BitKeeper.
  • 15. Some Git Goals • Speed • Simple design • Strong support for non-linear development (thousands of parallel branches) • Fully distributed • Able to handle large projects like the Linux kernel efficiently (speed and data size)
  • 16. Git Basics • Snapshots, Not Differences • Nearly Every Operation Is Local • Git Has Integrity • Git Generally Only Adds Data • The Three States
  • 17. Snapshots, Not Differences http://git-scm.com Differences
  • 18. Snapshots, Not Differences http://git-scm.com Snapshots
  • 19. Nearly Every Operation Is Local • You can work offline as look the history, commit some changes or create branchs
  • 20.
  • 21.
  • 22. Git Has Integrity • Git generate a SHA-1 hash for each commit associated a file • Git realize a checksum everytime is tried to store some change. So Git knows when something was changed or the file is corrupted 24b9da6552252987aa493b52f8696cd6d3b00373
  • 23. Git Generally Only Adds Data • Doing commits regularly it is very difficult to get the system to do anything that is not undoable or lose some change • Let us more comfortable to experiment changes, because is easy to recover a previous version
  • 24. The Three States http://git-scm.com Modified/Untracked Staged Committed
  • 26. So, what are we going to do? • Configure • Alias • Create a Repository • Diff • Passing through the 3 • Tag States • Ignoring Files and • Branch Folders • Merge • Getting a Remote • Log Repository • Basic Workflow
  • 27. Configure • Download and Install Git: http://git-scm.com/ • You just need the Git Bash to work
  • 28. Username git config --global user.name "Your Name Here" # Sets the default name for git to use when you commit Email git config --global user.email "your_email@example.com" # Sets the default email for git to use when you commit
  • 29. Create a Repository Access your project directory cd your_folder_name Create the repository git init Check the repository current status git status All your repository data and configuration is stored on a hidden folder named .git on your repository’s root
  • 30. Passing through the 3 States How is the status now? Create or Change a file/folder From Nowhere/Repository Working Directory touch file_name/folder How is the status now? Add objects to staging area Working Directory  Staging Area git add (general_comand/file_name/folder_name/…) How is the status now? Staging Area  Repository Save objects on local repository git commit –m ‘This is my awesome comment’ How is the status now?
  • 31. Adding, Removing and Renaming Stages All git add -A Stages new and modified, without deleted git add . Stages modified and deleted, without new git add -u Stages a removed file git rm file_name/ Stages a removed folder git rm -r folder_name/ Stages a renamed file git mv old_file_name new_file_name
  • 32. .gitignore Is a hidden file named .gitignore on your root’s repository that contains a list of all ignored files and folders, like: *.tmp x64/
  • 33. Diff Compare the working directory with local repository git diff HEAD file_name Compare the working directory with staging area git diff file_name Compare the index with local repository git diff --cached file_name Compare the branchs showing just the status and file name git diff --name-status branch_1 branch_2
  • 34. Custom Alias Create a new alias to show a log with graph git config --global --add alias.lol "log --graph -- decorate --pretty=oneline --abbrev-commit --all" Using the new alias git lol List all the local configurations git config –-local -l
  • 35. Branchs Create and Switch for a new branch git checkout –b branch_name List all local branchs git branch Switch for a existing branch git checkout branch_name Working with Remote Repositories Add a local branch for a remote repository git push remote_name branch_name Update local branch from a remote branch git pull remote_name branch_name
  • 36. Merges Merge on the current branch changes made on another branch git merge branch_name Before merge After merge
  • 37. Merge Conflicts Master Development Merge conflict Resolving the conflict Commit the file after resolve the conflict git commit –a -m ‘Resolving merge conflicts’
  • 38. Tags List all tags git tag Creating an annotated tag git tag -a tag_name -m 'message description' git tag -a v1.0 -m 'my version 1.0' Working with Remote Repositories Sharing tags git push origin v1.0 All tags git push origin --tags
  • 39. Git + Social Coding
  • 40. Add and Pull a Remote Repository Cloning a or repository git clone git@github.com:owner_repo/repo_name.git Actually what the clone command does is: remote add + pull git remote add origin git@github.com:owner_repo/repo_name.git git pull origin master And actually what the default pull command does is: fetch + merge Update local repository avoiding the amount of merges (fetch+rebase) git pull --rebase repo_name branch_name
  • 41. Pushing to the Remote Repository Pushing for the remote repository git push remote_name branch_name git push origin master
  • 42. Basic Workflow http://nakedstartup.com/2010/04/simple-daily-git-workflow
  • 43. Others helpful (or not) commands List of Git Contributors git shortlog -s -n Show the SHA1 of a file staged git ls-files -s file_name Show the SHA1 of a file modified git hash-object file_name Discard changes of a file git checkout --file_name
  • 44. Others helpful (or not) commands Undo git add before commit git reset HEAD file_name One line logs git log --pretty=oneline Short status git status -s Delete the last commit before Push git reset --hard HEAD~1
  • 46. Look more… • Using SSH security connections • Git Cheat Sheet Grey • http://git-scm.com