How to push changes in git using the command line?

Member

by enrico , in category: General Help , 11 days ago

How to push changes in git using the command line?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by albert , 11 days ago

@lonzo Git push lets you update the remote refs with the local refs, along with the objects that complete the given refs. If the local branch does not specify where to push to i.e remote configuration, it defaults to origin. When making a git push, you can push with arguments like –all, –mirrror, –tags e.t.c otherwise the configuration in the push. the default will be used.


If the current branch, is pushed to the upstream branch which does not have the same name as the local one, the push is aborted as a safety measure. The refs/heads namespace will only accept commit objects, and updates only if they can be fast-forwarded.


A few git arguments:

  • –all  – push all branches with refs/heads/
  • –prune – remove remote branches that don’t have a local counterpart
  • –dry-run – do everything except actually send the updates
  • –force-with-lease – protect all remote refs that will be updated by requiring the current value to be the same as the value for the remote tracking branch.
  • –force – add a + in-front of the refspec so as to push to only a single branch just in the case that push. default is set to matching or multiple destinations
  • –verbose – run verbosely

Usually, the git push command will be looks like this:

1
git push -u origin master