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 1035477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:32:54+00:00 2026-05-16T14:32:54+00:00

I squash some commits in Git using git rebase -i origin/master as mentioned in

  • 0

I squash some commits in Git using git rebase -i origin/master as mentioned in ReinH.com.

After squashing some commits, is there a way to see the original commits? Is it possible to get “diff” of the commits? Can I get the SHA?

If it’s possible, is that still possible after running git gc?

  • 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-16T14:32:54+00:00Added an answer on May 16, 2026 at 2:32 pm

    The point of squashing commits is to rewrite history, replacing the original commits with a single commit.

    That said, it’s hard to make things actually disappear in git. The easiest way to get at those commits will be via git reflog. Try git reflog <branch> for the previous positions of the branch which you rebased.

    You should be able to find the SHA1 of the tip of the branch just before your interactive rebase. (If the branch no longer exists, try git reflog show to see the reflog of HEAD. It should be there too, just more other activity to sort through.)

    Once you have the SHA1, you’re golden – use git log -p or gitk to view the commits and see their diffs. (If you want to do a lot with it, create a branch there, so you don’t have to paste the SHA1 over and over again.)

    This will still be possible after running git gc, as long as it hasn’t been a long time since you squashed those commits. gc only prunes unreachable dangling objects over a certain age.

    Commits are considered reachable if they’re reachable from anything in the reflogs, and reflogs take 90 days to expire, so you can generally count on those original commits hanging around for three months.

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

Sidebar

Related Questions

I want to squash some local commits using rebase -i but I have pulled
I don't quite understand how the commits are squashed with git rebase -i. There
I'd like to use git rebase -i to squash the commits that I have
Possible Duplicate: How can I squash my last X commits together using git? I
I'm using git-svn; I typically create a topic branch, make commits to it, then
I think I squashed the last 40 commits using rebase. I was following this
I've asked before about how to squash the first two commits in a git
I wanted to squash my last 2 commits into one, so did a git
I'm trying to understand the difference between a squash and a rebase. As I
After invoking git merge --no-commit <commit> , performing a commit will result in a

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.