1

I made a project on Android Studio and pushed the file to Github. My colleagues could pull that project and could work. I've made a few changes in the project myself, committed but when i push, it gives me the following error

Push rejected: Push to origin/master was rejected

I'm working on linux

I tried git push -u origin master and i get the following error

    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.
  • Does `git update` perform successfully? – Raptor Mar 09 '16 at 06:56
  • Possible duplicate of [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 Mar 09 '16 at 06:59

1 Answers1

2

Updated Answer

Since you are having problem with the .idea/workspace, you and other developers, should first add the .idea folder to your .gitignore file.

Since the .idea folder contains the IDE configuration files, they don't need to be tracked by the Git. For preventing the git from tracking this folder :

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

And then,

git push origin master

For more information on the same problem with the Intellij IDEA configuration files, you may refer to the following questions as well

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

This indicates that you should first update your local repository with the new commits that other developers have made and pushed to the remote.So :

git pull origin master

Then, do the merge and resolve the merge conflicts that may happen.

And then

git push origin master

or

git push -u origin master

will solve the issue and transfer your work to the remote repository.

Community
  • 1
  • 1
Farhad
  • 12,178
  • 5
  • 32
  • 60
  • After i use the git pull command, it says that i should commit the changes before i merge. I did that. But when i try pulling it again, it shows me the error and aborts the process. Here's the error: From https://github.com/devilape/Iimpacttest * branch master -> FETCH_HEAD error: Your local changes to the following files would be overwritten by merge: .idea/workspace.xml Please, commit your changes or stash them before you can merge. Aborting – Kushagra Chugh ੴ Mar 09 '16 at 09:15
  • My general policy with git: If 2-3 commands from first 3 stack overflow searches didn't solve the problem, then, 1. Generate a patch for local changes 2. Save the patch elsewhere 3. Delete the directory 4. Checkout a fresh copy 5. Apply the patch 6. Commit and Upload. 7. And tell myself, git.. pff.. :) – subin Mar 09 '16 at 10:07