Your affiliate is 2 lags behind

I have a branch of my main branch named 218.

I am the only one using this thread.

I make my changes 3 weeks ago to make a transfer request, but it was rejected because I needed to make changes.

Now I made these changes, and I wanted to commit the latest changes to my branch.

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

I disabled this: git reset --hard HEAD~1

And now, when it is in my repo on my computer, all the files are how they should be. But when I execute git status, my changes are not displayed 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 a branch what I have in my repo on my local computer, since it is standing, and not pull anything, but overwrite everything with what I have locally.

How to do it?

+9
git git-commit version-control git-merge
source share
3 answers

Since you only work with a branch, you can overwrite the state of the remote branch by doing git push --force .

Although you are sure that you are the only one on the branch? If you were the only one working in the branch, only your commits would be on the remote control, and you would not have to do git pull .

Running git push --force with a shared branch will cause much more problems for your team. Therefore, make sure that you want to delete 2 commits that are on the remote branch by following these steps:

 git checkout origin/feature/218 git log -3 

This will show that the last three commits (2 you are behind and the last one) on the remote control make sure that they belong to you and that you want the latter to be overwritten.

+14
source share
 git pull --rebase 

I think this will solve the problem.

+3
source share

If your branch is behind the master, then do:

 git checkout master (you are switching your branch to master) git pull git checkout yourBranch (switch back to your branch) git merge master 

After merging, check if there is a conflict or not.
If there is NO CONFLICT, then:

 git push 

If a conflict arises, correct your files, and then:

 git add yourFile(s) git commit -m 'updating my branch' git push 
0
source share

All Articles