achan1989
achan1989

Reputation: 101

getting rejected non fast forward issue in egit

I have done checkout from branch 2.0 .

Now I made changes to one of the file.
I want to commit it to branch i.e 2.0 branch,
So I right click on file , select team->commit option I ask me to select branch .

So I selected 2.0 and repository url. When I click , commit & push , on next box ,it is giving me confirmation box with expected push result as 2.0 [rejected-non-fast-forward].

Is it because of I am in develop group not in master ?
Also I able to changes on my local commit, but it is not reflected in master copy so is their any way to commit it to master copy.

Attached screenshot of confirm box.

enter image description here

Upvotes: 4

Views: 8445

Answers (4)

Himanshu
Himanshu

Reputation: 1

This error is shown because you have a gap between your working version in your local system and the committed version on GIT. So for this issue, you have to update your local version to the current version of GIT. After that, you can commit and push your code.

NOTE: PLEASE backup your changes in another location to paste them again in your local project.

Few steps you have to follow.

1) Roll back using soft reset - Go to history(where its showing all previous committed and push version)

Soft reset

Now your system is in the previous state ( before you committed the changes)

2) Rebase - Now you are rebase your local system to the current version committed on GIT using the rebase option. (in the rebase option it's already showing the latest committed changes of GIT)

Rebase part 1

Rebase part 2

3)Push & commit - Paste your changes backup in your local project. Then Your project (right click) > Team > commit. Finally, select the commit and push option and your changes go on GIT.

:)

Upvotes: 0

Atul
Atul

Reputation: 3347

For me .. Rebase was worked. After that I was able to push my changes to the reposiroty.

Upvotes: 0

Maulik Patel
Maulik Patel

Reputation: 670

I face same problem in My Eclipse Project and I tried Pull the all commit and than retry to push

enter image description here

Upvotes: 7

CodeWizard
CodeWizard

Reputation: 141946

Yep.

You try to push code from branch different to master and you cant.

How to fix it?

# commit all your changes to the desired branch (develop is i understand you correctly)

# checkout the master branch
git checkout master

# merge the changes from develop into master
git merge develop

# now push the changes
git push origin master.

The git merge created a new merge commit and now you can push it back to master.

Upvotes: 2

Related Questions