Articles → GIT → Push And Pull Command In Git
Push And Pull Command In Git
What Is Push Or Pull?
- Push means, uploading files from local folder to remote folder.
- Pull means, fetching files from remote folder to local folder.
Scenarios
- Local repository is cloned from the remote repository.
- 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
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
Click to Enlarge