Git Push Changes to Remote

Git Push Changes to Remote

 Git Push Changes to Remote

Use the git push command to copy local changes (Committed changes) to the remote git repository.


git push [remote_repository] [remote_branch]

Git Push Example

After committing all the new files or updated files, You can push your changes to the remote git repository using the “git push” command.

  • The default remote repository is referred to as the origin. You can find this with git remote -v command.
  • The default branch is used, master. You can find the current active branch with git branch command.
git push origin master

The above command will upload all changes to the origin remote repository under the master branch.

You can use the above command like below. Without branch name and origin, git push will use origin by default and it pushes our current active branch to the origin remote.

git push

Running example of git push command:

git push origin master

Counting objects: 5, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 11.90 KiB | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
   cd5dd84..3d31ae3  master -> master

Git Push Other Branches

You are working on a different local branch named “develop”. You can push changes of develop branch to remote develop branch by executing the command:

Make sure you are on develop branch using git branch command.

git push origin develop

In some cases, you may require to push your local branch to a remote branch with a different name. You can do this by specifying remote branch:

git push origin develop:remote-branch-name

Post a Comment