【问题标题】:Android Studio pushing to GithubAndroid Studio 推送到 Github
【发布时间】:2016-03-09 06:53:36
【问题描述】:

我在 Android Studio 上做了一个项目并将文件推送到 Github。我的同事可以拉那个项目并且可以工作。我自己对项目进行了一些更改,提交了但是当我推送时,它给了我以下错误

推送被拒绝:推送到源/主服务器被拒绝

我正在研究 linux

我试过 git push -u origin master 我收到以下错误

    To https://github.com/devilape/Iimpacttest.git
     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'https://github.com/devilape/Iimpacttest.git'
    hint: Updates were rejected because the tip of your current branch is behind
     hint: its remote counterpart. Integrate the remote changes (e.g.
     hint: 'git pull ...') before pushing again.
     hint: See the 'Note about fast-forwards' in 'git push --help' for details.

【问题讨论】:

标签: android linux git android-studio github


【解决方案1】:

更新答案

由于您在使用 .idea/workspace 时遇到问题,因此您和其他开发人员应首先将 .idea folder 添加到您的 .gitignore 文件中。

由于 .idea 文件夹包含 IDE 配置文件,Git 不需要跟踪它们。为了防止 git 跟踪这个文件夹:

git rm -r --cached .idea/
git commit -a -m "Removed .idea from being tracked by git"

然后,

git push origin master

有关 Intellij IDEA 配置文件相同问题的更多信息,您也可以参考以下问题

Git won't ignore files

git to ignore a hidden directory in the local repo


更新被拒绝,因为您当前分支的尖端落后 提示:它的远程对应物。集成远程更改

这表明您应该首先使用其他开发人员所做并推送到远程的新提交来更新您的本地存储库。所以:

git pull origin master

然后,进行合并,解决可能发生的合并冲突。

然后

git push origin master

或

git push -u origin master

将解决问题并将您的工作转移到远程存储库。

【讨论】:

  • 在我使用 git pull 命令后,它说我应该在合并之前提交更改。我这样做了。但是当我再次尝试拉动它时,它会向我显示错误并中止该过程。错误如下:来自github.com/devilape/Iimpacttest * branch master -> FETCH_HEAD 错误:您对以下文件的本地更改将被合并覆盖:.idea/workspace.xml 请在合并之前提交您的更改或存储它们。中止
  • 我对 git 的一般策略:如果前 3 次堆栈溢出搜索中的 2-3 条命令没有解决问题,那么,1. 为本地更改生成补丁 2. 将补丁保存在其他地方 3.删除目录 4. 签出新副本 5. 应用补丁 6. 提交并上传。 7. 告诉自己,git.. pff.. :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-26
  • 2018-04-29
相关资源
最近更新 更多