在Windows上使用Git将Project推送到Github

时间:2015-04-24 14:12:16

标签: git github github-for-windows

我正在尝试将我的django项目推向Gihub

我已经为Windows和Git CLI安装了Github

并遵循所有步骤

  1. 首先使用自述文件(默认)
  2. 在github上创建了一个Repo
  3. 创建了一个简单的django应用程序
  4. git init
  5. git add。
  6. git commit -m“First Commit”
  7. git remote add origin https://github.com/eMahtab/DjangoProject.git
  8. git push origin master
  9. 但在最后一步我收到错误

    To https://github.com/eMahtab/DjangoProject.git
    
    ! rejected        master -> master (fetch first)
    
    error: failed to push some refs to https://github.com/eMahtab/DjangoProject.git
    
    hint: Updates were rejected because the remote contains work that you do not have 
     locally. This is usually caused by another repository pushing to the same ref. You may 
     want to first integrate the remote changes (e.g., git pull ...) before pushing again.
     See the Note about fast-forwards in git push --help for details.
    

3 个答案:

答案 0 :(得分:0)

尝试:

git pull 

然后你可以推。

答案 1 :(得分:0)

如果git pull无法解决您的问题,请先尝试克隆项目并将代码复制到克隆的项目中。继续正常进行。这样git就可以为你配置远程跟踪主分支。你最后必须做git push

答案 2 :(得分:0)

这是一个经常出现的问题:

git push github master
To git@github.com:Answer_Bot-project/project.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:Answer_Bot-project/project.git'

经常重复出现的“解决方案”是使用以下命令的变体:

git fetch github; git merge github/master

Git non-fast-forward updates were rejected Merge the remote changes可能派上用场,它有很多关于你的问题的额外信息。

祝你好运!