Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between git push and git push origin master

I want to know that if I only use git command :

git push

and if I use

git push origin master

then, what is the difference between them?

I am working on gitlab and i have developer access to the project I am working on. I am using windows command line.

like image 937
mistletoe Avatar asked Apr 24 '17 16:04

mistletoe


People also ask

Is git push the same as git push origin?

Git push origin is usually used only where there are multiple remote repositories and you want to specify which remote repository should be used for the push. For a git push origin command: git push command updates remote references using local references by sending objects necessary to complete the given references.

What is git push origin master?

Origin is simply the name given to any remote repository available on GitHub. Whenever we need to push the changes to a remote repository, we use git push along with the remote repository “origin” and “master” branches. The term used is “git push origin master“.

What is the difference between origin and master in git?

The term "git origin master" is used in the context of a remote repository. It is used to deal with the remote repository. The term origin comes from where repository original situated and master stands for the main branch.

What does Origin mean in git push origin?

In Git, "origin" is a shorthand name for the remote repository that a project was originally cloned from. More precisely, it is used instead of that original repository's URL - and thereby makes referencing much easier.

What does git push origin master -- force do?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).

Should I push to master or main?

There is no difference. It's a default branch in Git which was changed previously it was master now it changes to main as a default branch.


1 Answers

git push: works like git push "remote", where "remote" is the current branch’s remote (or origin, if no remote is configured for the current branch).

and

git push origin master: Find a ref that matches master in the source repository (most likely, it would find refs/heads/master), and update the same ref (e.g. refs/heads/master) in origin repository with it. If master did not exist remotely, it would be created.

Please refer this for more information: link

like image 146
รยקคгรђשค Avatar answered Sep 30 '22 17:09

รยקคгรђשค