SlideShare ist ein Scribd-Unternehmen logo
1 von 10
Basic Git Commands 
Jitendra Zaa 
http://JitendraZaa.com
Add Existing folder as a Git repository 
Navigate to folder where code exist in your command line 
$ Git init
Add (Index) all existing files in Git repository 
$ Git add .
Set Global Git Name and Username 
• Every commit requires to know who is the user committing 
• So, we need to setup global Name and Username. This is onetime 
process 
• $ git config --global user.name 'Your Name' 
• $ git config --global user.email you@somedomain.com
Commit files added in git index 
• $ git commit --message “Your Initial Commit Message”
Add remote 
• Till now all files added and committed are saved on local system 
• You may want to move those files to server, Before that we need to 
add servers in remote list of git 
• $ git remote add <AnyUniqueName> <gitpath> 
• Note : Mostly “origin” is used for remote name 
• Example : git remote add origin https://github.com/user/repo.git
Get List of all Remote Added 
• $git remote
How Authentication works for remote 
• To push anything on remote Git server, we need to authenticate our 
self. 
• For this, we need to generate RSA key and store in remote git server. 
This is only one time process. You can refer below articles 
• Generate RSA key using Eclipse 
• Creating First Application in Heroku using Eclipse 
• Working with Git on Window 
• How to add public key in Bit bucket
Push Changes 
• Once remote repository is added we can push changes from local to 
remote repository 
• To check available remote repositories run - $git remote 
• $ Git push <RemoteNameAdded> <localBranchName> 
• Example : git push origin master
Push Fast Forward (Not Recommended) 
• You may get an error about fast-forward while committing to remote 
repository. This is because you remote repository already have some 
file which is not in synch with your local repository 
• Correct solution is to fetch from remote repository, merge and then 
try to commit again 
• However, in case you want to overwrite [Yes, Overwrite means you 
cannot see any history] remote files we can use “-fast” attribute 
• Example : git push origin master --fast

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Git 101
Git 101Git 101
Git 101
 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git Started With Git
Git Started With GitGit Started With Git
Git Started With Git
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Git101
Git101Git101
Git101
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
Git basic
Git basicGit basic
Git basic
 
Learning git
Learning gitLearning git
Learning git
 
Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners Git 101: Git and GitHub for Beginners
Git 101: Git and GitHub for Beginners
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Github basics
Github basicsGithub basics
Github basics
 
Introduction to Git (part 1)
Introduction to Git (part 1)Introduction to Git (part 1)
Introduction to Git (part 1)
 
Introduction to Git Commands and Concepts
Introduction to Git Commands and ConceptsIntroduction to Git Commands and Concepts
Introduction to Git Commands and Concepts
 
Git learning
Git learningGit learning
Git learning
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon Melbourne
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 

Ähnlich wie Basic Git commands

Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
Chris Miller
 
Git Introductive
Git IntroductiveGit Introductive
Git Introductive
Adham Saad
 

Ähnlich wie Basic Git commands (20)

Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
.Git for WordPress Developers
.Git for WordPress Developers.Git for WordPress Developers
.Git for WordPress Developers
 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
 
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
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
Gitting the Most From Git
Gitting the Most From GitGitting the Most From Git
Gitting the Most From Git
 
Let's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHubLet's Git this Party Started: An Introduction to Git and GitHub
Let's Git this Party Started: An Introduction to Git and GitHub
 
How to configure a Git repository and push to a remote repository…
How to configure a Git repository and push to a remote repository…How to configure a Git repository and push to a remote repository…
How to configure a Git repository and push to a remote repository…
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
Git Introductive
Git IntroductiveGit Introductive
Git Introductive
 
Git and github introduction
Git and github introductionGit and github introduction
Git and github introduction
 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git-r-Done
Git-r-DoneGit-r-Done
Git-r-Done
 
Using a Private Git Server for Packaging Software
Using a Private Git Server for Packaging SoftwareUsing a Private Git Server for Packaging Software
Using a Private Git Server for Packaging Software
 
Git is a distributed version control system .
Git is a distributed version control system .Git is a distributed version control system .
Git is a distributed version control system .
 
Beginner's guide to git and github
Beginner's guide to git and github Beginner's guide to git and github
Beginner's guide to git and github
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git training v10
Git training v10Git training v10
Git training v10
 

Mehr von Jitendra Zaa

Mehr von Jitendra Zaa (20)

Episode 13 - Advanced Apex Triggers
Episode 13 - Advanced Apex TriggersEpisode 13 - Advanced Apex Triggers
Episode 13 - Advanced Apex Triggers
 
Episode 18 - Asynchronous Apex
Episode 18 - Asynchronous ApexEpisode 18 - Asynchronous Apex
Episode 18 - Asynchronous Apex
 
Episode 15 - Basics of Javascript
Episode 15 - Basics of JavascriptEpisode 15 - Basics of Javascript
Episode 15 - Basics of Javascript
 
Episode 23 - Design Pattern 3
Episode 23 - Design Pattern 3Episode 23 - Design Pattern 3
Episode 23 - Design Pattern 3
 
Episode 24 - Live Q&A for getting started with Salesforce
Episode 24 - Live Q&A for getting started with SalesforceEpisode 24 - Live Q&A for getting started with Salesforce
Episode 24 - Live Q&A for getting started with Salesforce
 
Episode 22 - Design Pattern 2
Episode 22 - Design Pattern 2Episode 22 - Design Pattern 2
Episode 22 - Design Pattern 2
 
Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1Episode 21 - Design Pattern 1
Episode 21 - Design Pattern 1
 
Episode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in SalesforceEpisode 20 - Trigger Frameworks in Salesforce
Episode 20 - Trigger Frameworks in Salesforce
 
Episode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersEpisode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulers
 
Episode 17 - Handling Events in Lightning Web Component
Episode 17 - Handling Events in Lightning Web ComponentEpisode 17 - Handling Events in Lightning Web Component
Episode 17 - Handling Events in Lightning Web Component
 
Episode 16 - Introduction to LWC
Episode 16 - Introduction to LWCEpisode 16 - Introduction to LWC
Episode 16 - Introduction to LWC
 
Introduction to mulesoft - Alpharetta Developer Group Meet
Introduction to mulesoft - Alpharetta Developer Group MeetIntroduction to mulesoft - Alpharetta Developer Group Meet
Introduction to mulesoft - Alpharetta Developer Group Meet
 
Episode 12 - Basics of Trigger
Episode 12 - Basics of TriggerEpisode 12 - Basics of Trigger
Episode 12 - Basics of Trigger
 
Episode 11 building & exposing rest api in salesforce v1.0
Episode 11   building & exposing rest api in salesforce v1.0Episode 11   building & exposing rest api in salesforce v1.0
Episode 11 building & exposing rest api in salesforce v1.0
 
Episode 10 - External Services in Salesforce
Episode 10 - External Services in SalesforceEpisode 10 - External Services in Salesforce
Episode 10 - External Services in Salesforce
 
Episode 14 - Basics of HTML for Salesforce
Episode 14 - Basics of HTML for SalesforceEpisode 14 - Basics of HTML for Salesforce
Episode 14 - Basics of HTML for Salesforce
 
South East Dreamin 2019
South East Dreamin 2019South East Dreamin 2019
South East Dreamin 2019
 
Episode 9 - Building soap integrations in salesforce
Episode 9 - Building soap integrations  in salesforceEpisode 9 - Building soap integrations  in salesforce
Episode 9 - Building soap integrations in salesforce
 
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
Episode 8  - Path To Code - Integrate Salesforce with external system using R...Episode 8  - Path To Code - Integrate Salesforce with external system using R...
Episode 8 - Path To Code - Integrate Salesforce with external system using R...
 
Episode 6 - DML, Transaction and Error handling in Salesforce
Episode 6 - DML, Transaction and Error handling in SalesforceEpisode 6 - DML, Transaction and Error handling in Salesforce
Episode 6 - DML, Transaction and Error handling in Salesforce
 

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
[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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 

Basic Git commands

  • 1. Basic Git Commands Jitendra Zaa http://JitendraZaa.com
  • 2. Add Existing folder as a Git repository Navigate to folder where code exist in your command line $ Git init
  • 3. Add (Index) all existing files in Git repository $ Git add .
  • 4. Set Global Git Name and Username • Every commit requires to know who is the user committing • So, we need to setup global Name and Username. This is onetime process • $ git config --global user.name 'Your Name' • $ git config --global user.email you@somedomain.com
  • 5. Commit files added in git index • $ git commit --message “Your Initial Commit Message”
  • 6. Add remote • Till now all files added and committed are saved on local system • You may want to move those files to server, Before that we need to add servers in remote list of git • $ git remote add <AnyUniqueName> <gitpath> • Note : Mostly “origin” is used for remote name • Example : git remote add origin https://github.com/user/repo.git
  • 7. Get List of all Remote Added • $git remote
  • 8. How Authentication works for remote • To push anything on remote Git server, we need to authenticate our self. • For this, we need to generate RSA key and store in remote git server. This is only one time process. You can refer below articles • Generate RSA key using Eclipse • Creating First Application in Heroku using Eclipse • Working with Git on Window • How to add public key in Bit bucket
  • 9. Push Changes • Once remote repository is added we can push changes from local to remote repository • To check available remote repositories run - $git remote • $ Git push <RemoteNameAdded> <localBranchName> • Example : git push origin master
  • 10. Push Fast Forward (Not Recommended) • You may get an error about fast-forward while committing to remote repository. This is because you remote repository already have some file which is not in synch with your local repository • Correct solution is to fetch from remote repository, merge and then try to commit again • However, in case you want to overwrite [Yes, Overwrite means you cannot see any history] remote files we can use “-fast” attribute • Example : git push origin master --fast