git 使用总结

1、使用git push origin -u master 将本地的仓库master分支和远程仓库master 分支关联
出现异常:

$ git  push origin -u master
To [email protected]:JimGray11/Spark-study-java.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:JimGray11/Spark-study-java.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.

异常的主要原因:
github中的README.md文件不在本地代码目录中
解决办法:

可以通过如下命令进行代码合并【注:pull=fetch+merge]
git pull –rebase origin master

你可能感兴趣的:(Git)