【问题标题】:Pushing Project to Github using Git on Windows在 Windows 上使用 Git 将项目推送到 Github
【发布时间】:2022-04-23 21:39:37
【问题描述】:

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

我已经安装了 Github for windows 和 Git CLI

并遵循所有步骤

  1. 首先在 github 上使用自述文件创建了一个 Repo(默认)
  2. 创建了一个简单的 django 应用程序
  3. git 初始化
  4. git 添加。
  5. git commit -m "第一次提交"
  6. git远程添加源https://github.com/eMahtab/DjangoProject.git
  7. git push origin master

但在最后一步我遇到了错误

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.

【问题讨论】:

标签: git github github-for-windows


【解决方案1】:

尝试做:

git pull 

然后你就可以推送了。

【讨论】:

    【解决方案2】:

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

    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 可能会派上用场,其中包含很多关于您的问题的额外信息。

    祝你好运!

    【讨论】:

      【解决方案3】:

      如果git pull 不能解决您的问题,请先尝试克隆项目,然后将您的代码复制到克隆的项目中。照常进行。这样 git 应该会为你配置远程跟踪 master 分支。你只需要最后做一个git push

      【讨论】:

        【解决方案4】:

        省略master,因为master是用于Mac的,如果你想使用命令然后 输入git push origin

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-01-06
          • 1970-01-01
          • 2021-09-15
          • 2013-06-21
          • 1970-01-01
          • 2015-12-16
          • 1970-01-01
          相关资源
          最近更新 更多