How do I properly force a Git push

0 votes

I have cloned a remote non-bare main repo to my computer. Then I made some changes and updated my local repo. I also made a change in the remote repo but then I realized that I didn't need to, so   I tried to git push from my local repo to my remote repo, but I got an error like:

To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of git push --help for details.

Then I tried:

git push --force

I thought that this would force my local copy to push changes to the remote one and make it the same. But when I g to the remote repo and make a commit, I notice that the files contain outdated changes.
How can I fix this issue?

May 19, 2022 in Git & GitHub by Kichu
• 19,040 points
810 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Git & GitHub

0 votes
1 answer

How do I solve a Git checkout error: updating paths is incompatible with switching branches?

This error occurs when you are checking ...READ MORE

answered Jul 26, 2018 in Git & GitHub by Sophie may
• 10,620 points
10,530 views
+1 vote
1 answer

How do I rename a local Git branch?

Hi@akhtar, You can rename your branch name. Sometimes ...READ MORE

answered Sep 4, 2020 in Git & GitHub by MD
• 95,460 points
725 views
0 votes
1 answer

How do I go to a particular version of a file in the Git repository?

Hi@akhtar, You can use git checkout <sha1> to check ...READ MORE

answered Jan 5, 2021 in Git & GitHub by MD
• 95,460 points
2,913 views
0 votes
0 answers

How do I use git reset --hard HEAD to revert to a previous commit

When I revert this commit: git reset --hard ...READ MORE

May 15, 2022 in Git & GitHub by Kichu
• 19,040 points
876 views
0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,890 points
2,458 views
0 votes
1 answer

How do I install Git on windows?

Hey @Akash, follow these steps: Go to this ...READ MORE

answered Feb 19, 2019 in Git & GitHub by Nikhil
992 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,039 views
+2 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP