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.
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.
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“.
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.
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.
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).
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With