在使用git push时候遇到了这个问题:
Pushing to git@github.com:519ebayproject/519ebayproject.git
To git@github.com:519ebayproject/519ebayproject.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:violet227/learn_git.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
查阅了Stack Overflow后找到了解决办法。原文链接
This can cause the remote repository to lose commits; use it with care.
If you do not wish to merge the remote branch into your local branch (see differences with git diff), and want to do a force push, use the push command with -f
git push -f origin <branch>
where origin is the name of your remote repo.
Usually, the command refuses to update a remote ref that is not an ancestor of the local ref used to overwrite it. This flag disables the check. This can cause the remote repository to lose commits; use it with care.