I recently used this command
git push
I want to know what are the differences when I use these commands
git push origin master
git push -u
git push -f
I recently used this command
git push
I want to know what are the differences when I use these commands
git push origin master
git push -u
git push -f
The git push command allows you to send (or push) the commits from your local branch in your local Git repository to the remote repository.enter link description here
The most common use of git push is to push your local changes to your public upstream repository. Assuming that the upstream is a remote named “origin” (the default remote name if your repository is a clone) and the branch to be updated to/from is named “master” (the default branch name), this is done with:
git push origin master
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.
-u --set-upstream For every branch that is up to date or successfully pushed, add upstream (tracking) reference, used by argument-less git-pull and other commands. For more information, see branch..merge in git-config.
-f --force Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. Also, when --force-with-lease option is used, the command refuses to update a remote ref whose current value does not match what is
git push assumes that you already have a remote repository defined for that branch. In this case, the default remote origin is used. git push origin master indicates that you are pushing to a specific remote, in this case, origin . This would only matter if you created multiple remote repositories in your code base.