1

Does git push origin master do exactly the same thing as git push?

rst-2cv
  • 1,130
  • 1
  • 15
  • 31
Bob5421
  • 7,757
  • 14
  • 81
  • 175

1 Answers1

5

git push alone has been deprecated (not supported) for some time, because it is implicit, rather than explicit.

It is better practice, and not to mention much safer (will likely stop you from accidentally pushing the wrong branch to the wrong remote).

Thus, it is best to use git push <remote> <branch>

rst-2cv
  • 1,130
  • 1
  • 15
  • 31
  • Okay but was it the same thing before been deprecated ? – Bob5421 May 26 '18 at 11:46
  • and git pull without arguments is deprecated too ? – Bob5421 May 26 '18 at 11:47
  • 1
    AFAIK, `git push` pushed the currently checked-out branch to the `origin` remote. So, if `git status` said you were in the master branch, and `git remote -v` returned the remote `origin`, then `git push` would be the same as `git push origin master` – rst-2cv May 26 '18 at 11:48
  • Yes I believe `git pull` without any arguments is also deprecated. – rst-2cv May 26 '18 at 11:49
  • @RThomP Can you provide a reference for deprecation? I've never heard about deprecated bare `git pull/push`, docs don't say anything and search reveals nothing. – phd May 26 '18 at 14:45
  • It's not deprecated. Whether it's a good *habit* is another question entirely, but bad habit or not, I use it all the time... – torek May 26 '18 at 16:25