2016-03-09 108 views
1

我在Android Studio上创建了一个项目并将文件推送到Github。我的同事们可以拉动这个项目并且可以工作。我做了该项目的几个改变自己,致力于但是当我推开,它给了我下面的错误Android Studio推送到Github

Push rejected: Push to origin/master was rejected

我工作在Linux上

我试着混帐推-u起源主 我碰到下面的错误

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. 
+0

'git update'执行成功吗? – Raptor

+0

[Git push error'\ [remote rejected \] master - > master(branch is currently checked out)']可能重复'](http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected -master-master-branch-is-currently-checked) – paulsm4

回答

2

更新回答

既然你正与.idea/workspace,你和其他开发问题elopers,首先应该将.idea folder添加到.gitignore文件中。

由于.idea文件夹包含IDE配置文件,因此它们不需要由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


Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes

这表明您应该先更新您的本地资源库与新的承诺,其他开发人员制作并被推到了remote.So:

git pull origin master 

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

然后

git push origin master 

git push -u origin master 

将解决这个问题,你的工作转移到远程仓库。

+0

在我使用git pull命令之后,它说我应该在我合并之前提交更改。我做到了。但是,当我尝试再次拉它时,它会显示错误并中止该过程。这里的错误:从https://github.com/devilape/Iimpacttest *分支主 - > FETCH_HEAD 错误:您的本地更改以下文件将被合并覆盖: \t .idea/workspace.xml 请,在合并之前提交更改或隐藏它们。 正在中止 –

+0

我的git总体策略是:如果来自前3次堆栈溢出搜索的2-3条命令没有解决问题,则 1.为本地更改生成补丁 2.将补丁保存在别处 3.删除目录 4.检出新副本 5.应用补丁 6.提交并上载。 7.并告诉我自己,git .. pff .. :) – subin