Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

your branch is behind by 2 commits

I have a branch of my master branch called 218.

I am the only one using this branch.

I commit my changes 3 weeks ago looking to do a pull request, but it was rejected as I needed to make changes.

Now I have made those changes and I wanted to commit the latest changes to my branch.

I tried to commit and it told me I needed to merge and pull. So I did, and it messed up all my files and got rid of my changes I made in the last 3 weeks.

I undid this by: git reset --hard HEAD~1

And now as it stands in my repo on my computer all the files are how they should be. But when I do git status, my changes dont show and it says:

Your branch is behind 'origin/feature/218' by 2 commits, and can be fast forwarded. nothing to commit, working directory clean. 

I want to make the branch what I have currently in my repo on my local computer as it stands and not pull anything down but overwrite everything with what I have locally.

How do I do this?

like image 388
RSM Avatar asked Jan 26 '15 14:01

RSM


People also ask

How do I fix behind commits?

It means your copy of the remote master branch (typically denoted as origin/master) has n commits more than your local version of the master branch. You can resolve this, while you have master checked out, by typing: git merge origin/master.

What does it mean to be commits behind Main?

This means every locally created branch is behind. Before preceding, you have to commit or stash all the changes you made on the branch behind commits. Solution: Checkout your local Master branch git checkout master.


1 Answers

git pull --rebase

I guess this will solve the problem.

like image 101
Yogesh Kaushik Avatar answered Sep 28 '22 09:09

Yogesh Kaushik