Git Command Push

Push is a command we can use to upload local repo content to a remote repo.


Terminal example:

Terminal
>
git push
> Output:

remote: Resolving deltas: 100% (8/8), completed with 4 local objects.

When pushing remember what ObiWan said to Luke "Use the Force". It's often needed to use force flag. One time I often use force is when rebasing and then need to push. So for an example there we want to push to origin and use force.

Terminal
>
git push origin branchName --force
> Output:

+ 2339f78...59f9746 branchName -> branchName (forced update)

We can also use force with lease. This flag will protect all remote refs that are going to be updated.

Terminal
>
git push origin branchName --force-with-lease
> Output:

+ 2339f78...59f9746 branchName -> branchName (forced update)

Here is the official git docs page on git push.