Reputation: 1062
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?
Upvotes: 1
Views: 372
Reputation: 2254
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.
Upvotes: 1
Reputation: 12107
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:
After doing this with all conflicting files, test your code and run git commit
to merge. You will be able to push after that.
Upvotes: 2
Reputation: 4623
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)
Upvotes: 0