Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Git Tutorial
  • Git Exercises
  • Git Basic Commands
  • Git Cheat Sheet
  • Git Interview Questions
  • Git Bash
  • GitHub
  • Git Branch
  • Git Merge
  • Git WorkFlow
  • Git Hooks
  • Git LFS
  • Git Rebase
  • Git Cherry Pick
Open In App
Next Article:
Getting changes from a Git Repository
Next article icon

Getting changes from a Git Repository

Last Updated : 23 Jan, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
Git allows performing various operations on the Repositories including the local repositories and remote repositories. The user when downloads a project to work upon, a local repository is created to store a copy of the original project. This local repository stores the changes that are being made by the user. This way, the user can edit the changes before adding them to the main project. Multiple users can perform work on the same project at the same time by using local repositories. The central repository gets updated every time a user pushes the modifications done on the local repository. These changes do not get updated on the local repository of any other developer that is working on the same project. This might create confusion because different collaborators may end up contributing the same feature in the project. To avoid this, the collaborator updates the local copy on their machine every time before starting the work on their repository. This updation of local copy is done by downloading the recent copy of the project on the central repository. This process of updating the local repository is termed as Pulling or Fetching. Git provides git pull command and git fetch command to do the cloning of the central repository into the local repository. Pull command: Before starting the work on a project, the collaborator needs to clone his local repository with the central repository in order to get the latest copy of the project. This is done by the use of git pull command. This command updates the local repository immediately after its execution. Syntax:
git pull <remote> <branch-name>
git pull command is a combination of two other commands which are git fetch and git merge. Pulling from a remote repository Attributes of Pull Command: Pulling changes from the central repository can be done along with the use of certain attributes that can be used to perform multiple pull operations on the repository. These attributes can be used to perform specific pulls from the repository. These are:
  • --no-commit: By default git pull command when called will perform the merging of two branches and then automatically executes the commit operation to create a new commit. But, when the pull operation is called with --no-commit attribute, only the merging process is performed and the commit operation will not take place. Syntax:
    $ git pull <remote> --no-commit
  • --rebase: When a git pull command is called it will merge two branches and will create a separate branch which inherits the changes of both the branches being merged. This will create some confusion among the collaborators as an extra branch will be created. To avoid this confusion, this command is used. It will also create a separate branch that inherits the changes from both the branches but, the branch which is to be merged will be removed from the repository. Syntax:
    $ git pull <remote> <branch-name> --rebase
  • --verbose: This git pull method when called with the --verbose attribute, will display all the files and content that is being downloaded with the pull method. This will also print all the details of the merging process done by git pull. Syntax:
    $ git pull <remote> --verbose
  •   Fetch Command: This command works just like the git pull command, but the only difference between the both is that git fetch command will not perform the merge operation after cloning the repository. This command will update the remote-tracking branches i.e. the local branches that are stored in the remote repository. It will not update the local copy of the branches. This helps to review the changes that are being downloaded before merging those changes with the local repository. git pull command, on the other hand, performs fetching and merging both the operations. Hence, the collaborator will not be able to review the changes that are being downloaded.
git pull = git fetch + git merge
git-fetch Attributes of fetch command: Fetching changes from the central repository can be done along with the use of certain attributes that can be used to perform multiple fetch operations on the repository. These attributes can be used to perform specific fetch operations from the repository. These are:
  • --all: When the fetch command is used with --all attribute, it will fetch all the registered remotes along with their branches in a single call. Syntax:
    $ git fetch --all
  • --dry-run:This option will actually do not perform any action on the repository but will give a demo for the test run of the command on the repository. It will output the changes or actions that will take place on the execution of command but will not apply them. Syntax:
    $ git fetch --dry-run
Hence, git fetch and git pull both commands can be used to update the local repository with the central repository by downloading the latest changes from the central repository.

Next Article
Getting changes from a Git Repository

A

Abhinav96
Improve
Article Tags :
  • Git
  • GitHub

Similar Reads

    How To Clone a Repository From Gitlab?
    Cloning a repository in Git involves creating a local copy of a project from a remote server. This allows you to work on the project on your local machine and later push your changes back to the remote repository. GitLab, one of the popular platforms for hosting Git repositories, provides a straight
    3 min read
    How to Change the URI For a Remote Git Repository?
    Git is a distributed version control system that helps manage source code history. Sometimes, you may need to change the URI (URL) of a remote repository, for instance, when migrating to a new host or changing from HTTP to SSH. Here’s how you can accomplish this task. Changing the URI for a remote G
    2 min read
    How to Delete a File From a Git Repository?
    Managing files within a Git repository often involves adding new files, modifying existing ones, and sometimes, deleting files that are no longer needed. Deleting a file from a Git repository is a simple process, but it's essential to follow the correct steps to ensure that the repository remains co
    3 min read
    How to Delete a Git Repository
    GAs developers and software teams are collaborating on projects, the usability of version control systems like Git to track changes and manage codebases has increased a lot. Using Git, developers can create and maintain repositories, that store the complete history and versions of projects. However,
    6 min read
    How to Git Clone a Remote Repository?
    Git is a powerful version control system that allows developers to track changes, collaborate on code, and manage projects efficiently. One of the fundamental operations in Git is cloning a remote repository. This article will guide you through the process of cloning a remote Git repository. Prerequ
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences