Git Push Changes to Remote
Use git push command to copy local changes (Committed changes) to the remote git repository.
Syntax:
git push [remote_repository] [remote_branch]
Git Push Example
After committing all the new files or updated files, You can push your changes to remote git repository using “git push” command.
- The default remote repository referred as origin. You can find this with
git remote -v
command. - The default branch is used master. You can find 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 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) To https://github.com/tecrahul/tecadmin.net cd5dd84..3d31ae3 master -> master
Git Push Other Branches
You are working on different local branch named “develop”. You can push changes of develop branch to remote develop branch by executing command:
Make sure you are on develop branch using git branch
command.
git push origin develop
In some cases you may required 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