Articles → GIT → Push and pull command in git

Push and pull command in git






What is push or pull?







Scenarios











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