Git - Upload committed changes using Git Push

This article covers how to use the command 'Git Push'

You're at the stage where you've made changes in your code, staged those changes, and committed them to your local repository.

Great! But those changes still only exist on your machine. We need to upload these changes to the remote repository, and we can do so using git push:

git push <remote-name>

This will push any local commits on your current branch (i.e., the branch you are currently checked out on) to the remote repository.

The remote name is the name of the remote repository. Typically, this will be "origin".

If you have multiple branches you want to push at the same time, you can use the --all parameter:

git push --all <remote-name>

Alternatively, if you wish to push a specific branch, you can specify the branch after the remote name:

git push <remote-name> <branch-name>

If changes have been made on the remote repository since your commit, your local repository is likely behind.

You can still push the commit, but you may need to use the --force parameter, or -f for short:

git push -f <remote-name> <branch-name>

Commits can also be assigned tags. If you're using tags, you will also need to push these to the remote repository.

# Create a tag
git tag <tag-name>

# Push the tag to remote
git push --tags