1

I have a repo on gitlab with my project. I first commit and push this project on windows. After I create a VM on ubuntu and I copy paste my project folder on it. I continue my project on ubuntu and I did commit (without push). I didn'use anymore my windows project. Now when I want to push the project (ubuntu) I have error. I think I have conflict and merging problem. How can I push my project on the repo. I try to pull, fetch but nothing.

The error is :

! [rejected]        master -> master (non-fast-forward)
impossible to push references to 'repo'
tip: The updates were rejected because the head of the current branch is behind its remote peer. Integrate remote changes (eg 'git pull ...') before pushing again.

After that when I do a git pull origin master I have a lot of conflicts with many files.

Can you help me?

1
  • 1
    You shouldn't have copied the working copy, you should have cloned the repo from gitlab.
    – choroba
    Aug 19, 2015 at 9:35

3 Answers 3

2

You should do the git pull and resolve conflicting files. Open each one, fix it, then git add it. You will find the conflicting lines like that:

enter image description here

After doing this with all conflicting files, test your code and run git commit to merge. You will be able to push after that.

1

git is not allowing you to push, pull, fetch because you copy pasted the entire directory. This has copied the .git folder also which git creates on git init. Delete the .git folder and then reinitialize the git repository with git init.

This will create a new .git pointing according to the new path.

0

On git pull , git will merge the conflicting files , You need to solve the conflicts and commit again to push (git push origin master) updated code on git .

for more info check this link : rejected master -> master (non-fast-forward)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.