在github上创建仓库,在本地第一次执行push -u origin master 时,提示如下:
192:DetectFileEncoding Edward$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
To github.com:Edward125/DetectFileEncoding.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:Edward125/DetectFileEncoding.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
实际发现解决方法有两种
1,根据提示,使用git pull,将github上的分支和本地的分支合并
2,直接使用push -f origin master 强制push。