Articles → GIT → Push And Pull Command In Git

Push And Pull Command In Git






What Is Push Or Pull?


  1. Push means, uploading files from local folder to remote folder.
  2. Pull means, fetching files from remote folder to local folder.

Scenarios




  1. Local repository is cloned from the remote repository.
  2. Local repository is created and then connected to the remote server.



Local Repository Is Cloned From The Remote Repository




// Clone the local repository using the clone command
git clone <remote URL>

// Create a new file and add it in the staging directory
git add .

// Commit the change on the local repository
git commit -m <message>

// Pull changes from remote server
git pull 

// Push changes on remote server
git push




Picture showing the push and pull command when Local repository is cloned from the remote repository
Click to Enlarge


Local Repository Is Created And Then Connected To The Remote Server




// Initialize the local repository
git init

// Connect to the remote repository
git remote add origin <URL>

// Pull changes from remote server
git pull origin master

// Create a new file and add it in the staging directory
git add .

// Commit the change on the local repository
git commit -m <message>

// Push code
git push --set-upstream origin <branch name>

// Or you can use
// git push -u origin master


Picture showing the push and pull command when Local repository is created and then connected to the remote server
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, September 10, 2019
 
Updated On  -  Monday, June 7, 2021

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250