3

My remote is configured not to accept non-fast-foward commits.

The remote version is completely different from my local version. I want to override it. I dont want to merge or rebase anything. Moreover, my local repository started as a clean git init, not pulling from the server.

I did git push origin master --f but I get

remote: error: denying non-fast-forward refs/heads/master (you should pull first) 

I dont want to pull because it will merge with my version and I dont want.

What's the right procedure to follow?

1
  • Might --f be the error? Commented Mar 2, 2013 at 13:26

2 Answers 2

2

It’s either git push -f origin master or git push --force origin master but git push --f won’t work.

Sign up to request clarification or add additional context in comments.

2 Comments

It's worth reiterating that this will destroy all history of any branches you forcibly override. Those changes will be gone forever.
Actually, git only overrides the branch reference. The objects itself are not immediately deleted and still exist in the objects database (.git/objects). However, a git garbage collection would finally destroy those dangling objects after some time.
0

Since you are working in the same repo as you are going to push from, you need to pull first.

You can try to stash your changes :

git stash 

When i started with git i had this error a lot of times. My solution was to work in a different directory then i pull from, making sure it never conflicts

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.