What is the difference between git push and git push origin

I’m having trouble differentiating between the two git statements, how exactly does one differ? Or do they differ at all?

  • Reset Git to commit without changing HEAD to detached state
  • Git - How to remove a large file from commit history so I can push repository?
  • Git pull from command line prompts for username and password
  • git: Log for 'master' only goes back to date bug?
  • Git doesn't change working directory
  • git push says everything up to date when it definitely is not
  • Versioning with Visual Studio 2010 and HG
  • git-p4 submission failure
  • Techniques to handle a private and public repository?
  • Moving SVN repositories data with history as subfolders into another repository
  • Capistrano 3 runs every command twice (new install) - Configuration issue
  • How can I make files which were created with git bash (touch file) visible in Windows 8.1?
  • 3 Solutions collect form web for “What is the difference between git push and git push origin”

    git push will git push to the default remote

    git push origin will push to the remote named origin

    When you clone a repository, the default remote is origin and it is automatically as the default upstream. That’s why you may not see the difference.

    Although, if you init a repo locally, origin won’t be automatically created, e.g.:

    git init
    git remote add origin ssh://url/to/origin
    git push -u origin --all # note there is also other way to set up the upstream
    

    Note that the default remote could be named anything. origin is only a convention.

    It depends on whether you have multiple remote places to push to. git push without any arguments to the push action, uses the default remote of the active branch. (https://www.kernel.org/pub/software/scm/git/docs/git-push.html and search for “origin”).

    Your current branch can be set up to track a remote repo (in which case git push, without origin, would push to that repo), but if there’s nothing specified it tries for origin.

    (This is why when using heroku, you generally have to git push heroku, instead of just git push.)

    **git push** 
    

    will directly push the commited changes to the branch on which you are currently present.

    git push origin branchname 
    

    is used to specifically mention where should the code be pushed. It’s always a better option to use this in all cases.

    The keyword origin only references to the name used and can be changed in .git/config file in the project folder where git is initialized.

    In case of adding a local project to remote. you can either use

    git remote add ec2 ssh://username@path_to_project../home/ubuntu/ProjectDir.git

    or

    git remote add origin ssh://ubuntu@path_to_project../home/ubuntu/ProjectDir.git

    The corresponding changes will be reflected in ProjectDir/.git/config file.

    Git Baby is a git and github fan, let's start git clone.