Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6378601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:01:45+00:00 2026-05-25T02:01:45+00:00

Possible Duplicate: How to delete a 'git commit' I am new to git and

  • 0

Possible Duplicate:
How to delete a 'git commit'

I am new to git and I encountered a situation which I need some help with.
I cloned a remote repository to my PC, and then opened a new branch named “meir”.

For practice purposes I first commited some changes I’ve made on a file. Afterwards, I changed the file the way I wanted it to be and commited again. Then I pushed my local branch to the remote repository.

The problem is that I have the first commit which was a test and I would not like it to be on the remote server. I thought about 2 possible ways to fix it:

  1. Remove the remote “meir” branch on the local and remote repository and start over.
  2. Remove only the first commit and then push the branch again to the server so it will also lose the first commit.

What commands do I need to run to achieve each of the options?

Thanks,
Meir

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:01:46+00:00Added an answer on May 25, 2026 at 2:01 am

    Generally speaking, you should not change commit history after you have pushed to public branch in a remote repository. It will cause pain to people who have pulled/cloned from the remote repository.

    But if you really want to do it, you could use interactive rebase and forced push:

    1. Use git rebase -i to squash the first commit with the second so that the local branch
      is setup the way you want the remote branch to be.
    2. Use git push -f (with proper branch spec) to “force push” to remote branch. Normal git push without -f will complain that the push is not a fast-forward push and will deny it.

    Another option is to remove the remote branch ‘meir’ with git push origin :meir, resturcture your local repository with git rebase -i and then push as normally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: delete[] supplied a modified new-ed pointer. Undefined Behaviour? Let's say I've allocated
Possible Duplicate: Any reason to overload global new and delete? In c++ you can
Possible Duplicate: How to delete an element from an array in php? For instance,
Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: How does delete[] “know” the size of the operand array? Assume i
Possible Duplicate: XmlSerializer: remove unnecessary xsi and xsd namespaces I'm generating some XML using
Possible Duplicate: Restore a deleted file in a Git repo How do I restore
Possible Duplicate: Can we delete an SMS in Android before it reaches the inbox?
Possible Duplicate: Is there any danger in calling free() or delete instead of delete[]?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.