Pull and Push changes
Pull
Pull operation copies the changes from a remote repository instance to a local one. The pull
operation is used for synchronisation between two repository instances.
If other team members are working on your repository, you can retrieve the latest changes made to the remote repository. fetch and merge any commits from the tracking remote branch. It gets all commits from the main repository (server).
$ git pull <remote> <branch>
If you want to push a branch to a remote repository you can use the command below.
Just remember to add -u to create the branch upstream.
You must have one or more commits in order to push.
Push
Push operation copies changes from a local repository instance to a remote one. This is used to
store the changes permanently into the Git repository. This is same as the commit operation in
Subversion.
Push local changes to the remote. Use --tags to push tags. It updates remote refs along with associated objects.
$ git push [--tags] <remote> <branch>
Do not use the --force flag unless you’re absolutely sure you know what you’re doing.
git push --force <remote> <branch>
Push local branch to remote repository. Set its copy as an upstream.
$ git push -u <remote> <branch>
Push all of your local branches to the specified remote.
$ git push <remote> --all
Note: As your local repository is not pushed to the server and not linked to a remote repository you need to set remote by,
$ git remote add origin <Repo url>
In case you already have set remote and you want to change URL you can do so by,
$ git remote set-url origin <New Repo URL>
Previous Next